Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

update from origin #1

Open
wants to merge 39 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
39 commits
Select commit Hold shift + click to select a range
fe32204
Issue #8 - AssertString:IsNotNullOrEmpty does not use failMessage
msabbott Jul 21, 2014
b81dc3a
Fixes #10 - JUnit Package name
msabbott Aug 28, 2014
f848ef8
Merge pull request #9 from msabbott/master
CameronWills Sep 30, 2014
3f323c6
Merge pull request #11 from msabbott/#10_-_JUnit_Reporter_Package
CameronWills Sep 30, 2014
bc5c962
Add NamedList class to OEUnit.Util and matching unit tests
msabbott Oct 14, 2014
36cfac5
Add core DataProvider class, error class, and associated unit tests
msabbott Oct 30, 2014
d733cbb
Ensure new Data directory is included when all unit tests are run.
msabbott Oct 30, 2014
469cb2c
Define new annotation types, and attribute types
msabbott Oct 30, 2014
56949ac
Allow multiple attributes to be defined inside of one annotation
msabbott Nov 3, 2014
25c29a9
Remove definitions of, and references to, AnnotationInfo:AttributeNam…
msabbott Nov 4, 2014
4d8ec25
Add methods to MethodInfo to Invoke a method with a ParameterList obj…
msabbott Nov 4, 2014
9265be3
Change OEUnitRunner to recognise test methods which require a DataPro…
msabbott Nov 4, 2014
0d30ab1
Add documentation for DataProviders
msabbott Nov 5, 2014
3190132
Add functionality to load DataProvider data from XML
msabbott Nov 5, 2014
d412826
Add 'FromTempTable' method to DataProvider to allow data and schema t…
msabbott Nov 5, 2014
fc4b6b4
Merge pull request #13 from msabbott/DataProvider
CameronWills Dec 15, 2014
ce5e599
Create class to hold Fixture data as a DataSet, and associated error …
msabbott Dec 16, 2014
6a9c850
Add annotation and attribute names for Fixtures
msabbott Dec 16, 2014
8dafc04
Add unit tests for Fixtures
msabbott Dec 17, 2014
1176b50
Refactor MethodInfo:GetDataProviderInfo into GetAssociatedMethodInfo …
msabbott Dec 17, 2014
840cd9c
Add functionality to MethodInfo to return Fixture information
msabbott Dec 17, 2014
753f601
Refactor RunTestMethod to include Fixtures and to create a transactio…
msabbott Dec 18, 2014
8e45f2c
Duplicate functionality from OEUnit.Data.Fixture to OEUnit.Data.Fixtu…
msabbott Dec 22, 2014
27c1bf5
Refactor Fixture to use FixtureDataSet, and to store multiple dataset…
msabbott Dec 22, 2014
78e07c5
Change name of several tests for Fixture class to better reflect thei…
msabbott Dec 22, 2014
78e13b3
Remove unrequired dsData property from Fixture class
msabbott Dec 22, 2014
eb1a513
Refactor unit tests for Fixture class, and implement test for multipl…
msabbott Dec 22, 2014
3926d7d
Resolve issue with incorrect class used in FixtureDataSetTest
msabbott Dec 22, 2014
4f757b5
Ensure that a transaction is in place before using fixture data
msabbott Dec 22, 2014
ef8db70
Add documentation for fixtures
msabbott Dec 22, 2014
cdc28f7
Resolve issue with Fixture datasets when loaded from Temp-Tables wher…
msabbott Dec 23, 2014
172a443
Add checks to ensure that Fixture data is only created when required,…
msabbott Jan 21, 2015
5ccc83a
Merge pull request #14 from msabbott/Fixtures
msabbott May 15, 2015
1876ceb
Apply workaround for issue #15 since Progress changed something in Op…
Nov 30, 2015
bcfc5e4
Merge pull request #16 from LievenDeFoor/lievendf/FixWaitForBug
msabbott Nov 30, 2015
797d202
OEUnit can handle more unit tests.
Aug 3, 2016
8f1d83d
OEUnit can handle more unit tests.
Aug 3, 2016
2d2aa20
Merge pull request #17 from jorenblancquaert/jorenblancquaert/fix-no-…
msabbott Aug 3, 2016
b494161
Updated readme.md
CameronWills Oct 23, 2019
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions doc/changelog.html
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ <h2>OEUnit - Unit Testing Framework</h2>
<li><a href="testsuite.html">Writing a Test Suite</a></li>
<li><a href="runningtests.html">Running a Test</a></li>
<li><a href="reportingtests.html">Reporting Test Results</a></li>
<li><a href="dataprovider.html">DataProviders</a></li>
<li><a href="fixtures.html">Fixtures</a></li>
<li><a href="license.html">License</a></li>
<li>Change Log</li>
</ul>
Expand Down
214 changes: 214 additions & 0 deletions doc/dataprovider.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,214 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<link rel="stylesheet" type="text/css" href="style.css" />
<title>OEUnit - DataProviders</title>
</head>
<body>
<table class="menu" cellpadding="10" cellspacing="0">
<tr>
<td>
<h2>OEUnit - Unit Testing Framework</h2>
<ul class="menuItems">
<li><a href="index.html">Overview</a></li>
<li><a href="installation.html">Installation</a></li>
<li><a href="testcase.html">Writing a Test Case</a></li>
<li><a href="testsuite.html">Writing a Test Suite</a></li>
<li><a href="runningtests.html">Running a Test</a></li>
<li><a href="reportingtests.html">Reporting Test Results</a></li>
<li>DataProviders</li>
<li><a href="fixtures.html">Fixtures</a></li>
<li><a href="license.html">License</a></li>
<li><a href="changelog.html">Change Log</a></li>
</ul>
</td>
</tr>
</table>
<h1>
DataProviders
</h1>
<h2>What is a DataProvider?</h2>
<p>
A DataProvider is a class method inside of a test case, which provides data which is passed
to individual test methods as method parameters.<br />
<br />
A test method declares that is requires a DataProvider when it is defined, using the <code>dataProvider</code>
attribute, supplying the name of a DataProvider method as the attribute value.<br />
<br />
A class method is defined with the <code class="keyword">@DataProvider</code> annotation, with an optional
<code>name</code> attribute. This method returns an object of type <code>OEUnit.Data.DataProvider</code> which
contains the data that will be used to repeatedly invoke the test method.
</p>
<h2>How to use a DataProvider</h2>
<p>
1. Define a test method, with <code class="keyword">INPUT</code> parameters for each test variable.<br />
Use the <code>dataProvider</code> attribute to specify the name of a class method which will provide data
for the test variables.<br />
For example:</p>
<pre class="code"> <span class="keyword">ROUTINE-LEVEL ON ERROR UNDO, THROW.

USING</span> OEUnit.Assertion.Assert.
<span class="keyword">USING</span> OEUnit.Data.DataProvider.

<span class="keyword">CLASS</span> SimpleTest:

@Test (dataProvider=StatusChangeProvider).
<span class="keyword">METHOD PUBLIC VOID</span> AcceptStatusChange(<span class="keyword">INPUT</span> varStatus AS CHARACTER, <span class="keyword">INPUT</span> varAccepted AS LOGICAL):
<span class="keyword">DEFINE VARIABLE</span> result <span class="keyword">AS LOGICAL NO-UNDO.</span>
result = Order:ChangeStatus(INPUT varStatus).
Assert:AreEqual(result,varAccepted).
<span class="keyword">END METHOD</span>.

<span class="keyword">END CLASS</span>.</pre>
<p>
<br />
2. Add a method to the class which returns a DataProvider object.<br />
Use the <code class="keyword">@DataProvider</code> annotation to indicate that the class is a DataProvider method.<br/>
For example:</p>
<pre class="code"> @DataProvider.
<span class="keyword">METHOD PUBLIC </span>DataProvider StatusChangeProvider():
<span class="keyword">DEFINE VARIABLE</span> dataProvider <span class="keyword">AS</span> DataProvider <span class="keyword">NO-UNDO</span>.
dataProvider = <span class="keyword">NEW</span> DataProvider().
dataProvider:FromJSON(<span class="literal">"~{ ~"data~": ["
+ "~{ ~"status~": ~"NEW~", ~"accepted~": true},"
+ "~{ ~"status~": ~"ACCEPTED~", ~"accepted": true},"
+ "~{ ~"status~": ~"PICKING~", ~"accepted": true},"
+ "~{ ~"status~": ~"POSTED~", ~"accepted": false},"
+ "~{ ~"status~": ~"DELIVERED~", ~"accepted": false},"
+ "~{ ~"status~": ~"CANCELLED~", ~"accepted": true},"
+ "]}"</span>).
<span class="keyword">RETURN</span> dataProvider.
<span class="keyword">END METHOD</span>.</pre> <p class="important">
<b>
<br />
Important Notes:</b></p>
<ul style="margin-top: auto;">
<li>The name of the <code>DataProvider</code> class method must match the value of the <code>dataProvider</code>
attribute on the test method, <i>or</i> the <code class="keyword">@DataProvider</code> annotation must
have a <code>name</code> attribute which matches the value of the <code>dataProvider</code>
attribute on the test method.</li>
<li>Execution of a DataProvider method will stop when an assertion fails or a <code>Progress.Lang.Error</code>
is thrown.</li>
<li>There are no special naming requirements for DataProvider methods.</li>
<li>DataProvider methods must be <code class="keyword">PUBLIC</code></li>
<li>DataProvider methods must accept no parameters.</li>
<li>DataProvider methods can be <code class="keyword">STATIC</code>.</li>
<li>DataProvider methods can be used by more than one test method.</li>
<li>Any <code class="keyword">@Before</code> methods are run before each test method invocation.</li>
<li>Any <code class="keyword">@After</code> methods are run after each test method invocation.</li>
</ul>
<p>
<br />
3. Run the test case as per normal.</p>
<p>
<br />
4. In the test case results, the test method will be listed multiple times with a separate status per invocation.</p>
<a name="methods"></a>
<h2>Name Attribute</h2>
<p>
Each method annotated with <code>@DataProvider</code> can specify a name attribute which is used
when searching for a DataProvider method, instead of the method name.
</p>
<p>
<b>Syntax:</b></p>
<p class="syntax">
<pre> @DataProvider[(name="<i>DataProviderName</i>")].</pre></p>
<p class="syntax">
<i><b>DataProviderName</b></i><br />
&nbsp;&nbsp;&nbsp; The Name of the DataProvider. This name can then be specified by
a test method as its DataProvider, in the <code>dataProvider</code> attribute<br />
</p>
<p>
<b>
<br />
Example:</b>
</p>
<pre class="code"> @Test (dataProvider=StatusChangeProvider).
<span class="keyword">METHOD PUBLIC VOID</span> AcceptStatusChange(<span class="keyword">INPUT</span> varStatus AS CHARACTER, <span class="keyword">INPUT</span> varAccepted AS LOGICAL):
<span class="keyword">DEFINE VARIABLE</span> result <span class="keyword">AS LOGICAL NO-UNDO.</span>
result = Order:ChangeStatus(INPUT varStatus).
Assert:AreEqual(result,varAccepted).
<span class="keyword">END METHOD</span>.

@DataProvider(name=StatusChangeProvider).
<span class="keyword">METHOD PUBLIC </span>DataProvider myDataProvider():
<span class="keyword">DEFINE VARIABLE</span> dataProvider <span class="keyword">AS</span> DataProvider <span class="keyword">NO-UNDO</span>.
dataProvider = <span class="keyword">NEW</span> DataProvider().
dataProvider:FromJSON(<span class="literal">"~{ ~"data~": ["
+ "~{ ~"status~": ~"NEW~", ~"accepted~": true},"
+ "~{ ~"status~": ~"ACCEPTED~", ~"accepted": true},"
+ "~{ ~"status~": ~"PICKING~", ~"accepted": true},"
+ "~{ ~"status~": ~"POSTED~", ~"accepted": false},"
+ "~{ ~"status~": ~"DELIVERED~", ~"accepted": false},"
+ "~{ ~"status~": ~"CANCELLED~", ~"accepted": true},"
+ "]}"</span>).
<span class="keyword">RETURN</span> dataProvider.
<span class="keyword">END METHOD</span>.</pre>
<h2>DataProvider Methods</h2>
<p>The DataProvider class provides a range of methods for loading data into the DataProvider.</p>
<p><b>METHOD PUBLIC LOGICAL FromJSON(INPUT json AS LONGCHAR)</b></p>
<p>This method is used to load data from JSON text stored in a <span class="keyword">LONGCHAR</span>.</p>
<p class="important">
<b>
<br />
Notes:</b></p>
<ul style="margin-top: auto;">
<li>The structure of the JSON data should match that which is accepted by an OpenEdge <span class="keyword">DATASET</span>
or <span class="keyword">TEMP-TABLE</span> when using the <span class="keyword">READ-JSON</span> method.</li>
<li>The method will return <span class="keyword">TRUE</span> if the data was successfully loaded.</li>
</ul>
<p><b>METHOD PUBLIC LOGICAL FromJSONFile(INPUT path AS CHARACTER):</b></p>
<p>This method is used to load data from JSON text stored in a file. The file path should be provided as the
<span class="keyword">INPUT</span> parameter.</p>
<p class="important">
<b>
<br />
Notes:</b></p>
<ul style="margin-top: auto;">
<li>The structure of the JSON data in the file should match that which is accepted by an OpenEdge
<span class="keyword">DATASET</span> or <span class="keyword">TEMP-TABLE</span> when using the
<span class="keyword">READ-JSON</span> method.</li>
<li>The method will return <span class="keyword">TRUE</span> if the data was successfully loaded.</li>
</ul>
<p><b>METHOD PUBLIC LOGICAL FromXML(INPUT xml AS LONGCHAR)</b></p>
<p>This method is used to load data from XML data stored in a <span class="keyword">LONGCHAR</span>.</p>
<p class="important">
<b>
<br />
Notes:</b></p>
<ul style="margin-top: auto;">
<li>The structure of the XML data should match that which is accepted by an OpenEdge <span class="keyword">DATASET</span>
or <span class="keyword">TEMP-TABLE</span> when using the <span class="keyword">READ-XML</span> method.</li>
<li>The method will return <span class="keyword">TRUE</span> if the data was successfully loaded.</li>
<li>It is advised to specify the XML Schema in the XML data in order for data types to be correctly interpreted.</li>
</ul>
<p><b>METHOD PUBLIC LOGICAL FromXMLFile(INPUT path AS CHARACTER):</b></p>
<p>This method is used to load data from XML data stored in a file. The file path should be provided as the
<span class="keyword">INPUT</span> parameter.</p>
<p class="important">
<b>
<br />
Notes:</b></p>
<ul style="margin-top: auto;">
<li>The structure of the XML data in the file should match that which is accepted by an OpenEdge
<span class="keyword">DATASET</span> or <span class="keyword">TEMP-TABLE</span> when using the
<span class="keyword">READ-XML</span> method.</li>
<li>The method will return <span class="keyword">TRUE</span> if the data was successfully loaded.</li>
<li>It is advised to specify the XML Schema in the XML data in order for data types to be correctly interpreted.</li>
</ul>
<p><b>METHOD PUBLIC LOGICAL FromTempTable(INPUT ttSrc AS HANDLE):</b></p>
<p>This method is used to load data from an existing temp-table, via the provided <span class="keyword">HANDLE INPUT</span> parameter.</p>
<p class="important">
<b>
<br />
Notes:</b></p>
<ul style="margin-top: auto;">
<li>The entire data and metaschema of the temp-table are copied.</li>
<li>Data is copied in EMPTY mode</li>
<li>The data and metaschema of the provided source temp-table are not affected.</li>
<li>The method will return <span class="keyword">TRUE</span> if the data was successfully loaded.</li>
</ul>
<div class="footer">
Cameron Wills, 2011.</div>
</body>
</html>
Loading