git-svn-id: https://svn.apache.org/repos/asf/ant/core/trunk@276341 13f79535-47bb-0310-9956-ffa450edef68master
@@ -4,7 +4,8 @@ | |||||
<property name="build.dir" location="assertions/build"/> | <property name="build.dir" location="assertions/build"/> | ||||
<property name="src.dir" location="assertions"/> | <property name="src.dir" location="assertions"/> | ||||
<property name="classname" value="AssertionTest"/> | |||||
<property name="classname" value="AssertionMain"/> | |||||
<property name="test.classname" value="AssertionTest"/> | |||||
<path id="assert.classpath"> | <path id="assert.classpath"> | ||||
<pathelement location="${build.dir}"/> | <pathelement location="${build.dir}"/> | ||||
@@ -150,4 +151,21 @@ | |||||
</java> | </java> | ||||
</target> | </target> | ||||
<target name="test-junit" depends="setup"> | |||||
<junit fork="true" | |||||
haltonerror="true" haltonfailure="true" | |||||
> | |||||
<classpath> | |||||
<path refid="assert.classpath"/> | |||||
</classpath> | |||||
<formatter type="plain" usefile="false"/> | |||||
<assertions enablesystemassertions="true"> | |||||
<enable package="..." /> | |||||
</assertions> | |||||
<test name="${test.classname}"/> | |||||
</junit> | |||||
</target> | |||||
</project> | </project> |
@@ -0,0 +1,30 @@ | |||||
/* | |||||
* Copyright 2003-2004 The Apache Software Foundation | |||||
* | |||||
* Licensed under the Apache License, Version 2.0 (the "License"); | |||||
* you may not use this file except in compliance with the License. | |||||
* You may obtain a copy of the License at | |||||
* | |||||
* http://www.apache.org/licenses/LICENSE-2.0 | |||||
* | |||||
* Unless required by applicable law or agreed to in writing, software | |||||
* distributed under the License is distributed on an "AS IS" BASIS, | |||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | |||||
* See the License for the specific language governing permissions and | |||||
* limitations under the License. | |||||
* | |||||
*/ | |||||
/** | |||||
* this is an assertion tester | |||||
* It has a main() entry | |||||
*/ | |||||
public class AssertionMain { | |||||
public static void main(String args[]) { | |||||
assert true == false : "there exist no facts that are both true and false"; | |||||
System.out.println("Assertions are disabled"); | |||||
} | |||||
} |
@@ -15,15 +15,30 @@ | |||||
* | * | ||||
*/ | */ | ||||
import junit.framework.TestCase; | |||||
/** | /** | ||||
* this is an assertion tester | |||||
* this is an assertion tester for junit | |||||
*/ | */ | ||||
public class AssertionTest { | |||||
public class AssertionTest extends TestCase { | |||||
public static void main(String args[]) { | |||||
assert true == false : "there exist no facts that are both true and false"; | |||||
System.out.println("Assertions are disabled"); | |||||
} | |||||
public AssertionTest(String name) { | |||||
super(name); | |||||
} | |||||
public void testAssertRaised() { | |||||
try { | |||||
assert true == false; | |||||
fail("expected an assertion"); | |||||
} catch(AssertionError asserto) { | |||||
//if we got here, all was well | |||||
} | |||||
} | |||||
public void testAssertNotRaised() { | |||||
assert(2+2==4); | |||||
} | |||||
} | } |
@@ -90,6 +90,9 @@ public class AssertionsTest extends BuildFileTest { | |||||
} | } | ||||
public void testJunit() { | |||||
executeTarget("test-junit"); | |||||
} | |||||
} | } | ||||