diff options
author | mclarke <mclarke@unknown> | 2014-04-18 21:00:38 +0000 |
---|---|---|
committer | mclarke <mclarke@unknown> | 2014-04-18 21:00:38 +0000 |
commit | b61c80746dd5df73899390826e197d2656784f91 (patch) | |
tree | e6713f841c480d0f1cf5161fa8ec27714d03f765 /manual/tutorial-tasks-filesets-properties.html | |
parent | 7eab7687db21f8a0c35b66dd9fae9e7c1178d5d5 (diff) | |
download | ant-b61c80746dd5df73899390826e197d2656784f91.tar.gz |
Test improvements: convert to JUnit4, improved error testing and remove sleeps
git-svn-id: https://svn.apache.org/repos/asf/ant/core/trunk@1588563 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'manual/tutorial-tasks-filesets-properties.html')
-rw-r--r-- | manual/tutorial-tasks-filesets-properties.html | 40 |
1 files changed, 28 insertions, 12 deletions
diff --git a/manual/tutorial-tasks-filesets-properties.html b/manual/tutorial-tasks-filesets-properties.html index 5ba08f6ef..fdbe1be5b 100644 --- a/manual/tutorial-tasks-filesets-properties.html +++ b/manual/tutorial-tasks-filesets-properties.html @@ -135,20 +135,28 @@ to them, sorry :-)</p> we can call that from our testcase: <pre class="code"> -import org.apache.tools.ant.BuildFileTest; +import org.junit.Rule; +import org.junit.Test; +import org.junit.Before; +import org.junit.Assert; +import org.apache.tools.ant.BuildFileRule; -public class FindTest extends BuildFileTest { - public FindTest(String name) { - super(name); - } +public class FindTest { + + @Rule + public final BuildFileRule buildRule = new BuildFileRule(); + + @Before public void setUp() { configureProject("build.xml"); } + @Test public void testSimple() { - <b>expectLog("use.simple", "test-value");</b> + buildRule.executeTarget("useSimgle"); + <b>Assert.assertEquals("test-value", buildRule.getLog());</b> } } </pre> @@ -211,10 +219,14 @@ Maybe you find some more testcases. But this is enough for now.<br> For each of these points we create a <tt>testXX</tt> method.</p> <pre class="code"> -public class FindTest extends BuildFileTest { +public class FindTest { + + @Rule + public final BuildFileRule buildRule = new BuildFileRule(); ... // constructor, setUp as above + @Test public void testMissingFile() { <b>Find find = new Find();</b> try { @@ -227,6 +239,7 @@ public class FindTest extends BuildFileTest { } } + @Test public void testMissingLocation() { Find find = new Find(); <b>find.setFile("ant.jar");</b> @@ -238,6 +251,7 @@ public class FindTest extends BuildFileTest { } } + @Test public void testMissingFileset() { Find find = new Find(); find.setFile("ant.jar"); @@ -250,15 +264,17 @@ public class FindTest extends BuildFileTest { } } + @Test public void testFileNotPresent() { - executeTarget("testFileNotPresent"); - String result = getProject().getProperty("location.ant-jar"); + buildRule.executeTarget("testFileNotPresent"); + String result = buildRule.getProject().getProperty("location.ant-jar"); assertNull("Property set to wrong value.", result); } + @Test public void testFilePresent() { - executeTarget("testFilePresent"); - String result = getProject().getProperty("location.ant-jar"); + buildRule.executeTarget("testFilePresent"); + String result = buildRule.getProject().getProperty("location.ant-jar"); assertNotNull("Property not set.", result); assertTrue("Wrong file found.", result.endsWith("ant.jar")); } @@ -906,7 +922,7 @@ entry. For both we need some information:</p> </tr> <tr> <th>attachments</th> - <td><i>all files needed to apply the path</td> + <td><i>all files needed to apply the path</i></td> <td>Archive containing a patch with the new and modified resources</td> </tr> </table> |