JUnit Test 'assertFalse' Example Using Ant
This example illustrates about how to use the 'assertFalse' assertion method to test whether the class file executed test cases successfully or not. In case of true return, it throw a error that is,
[junit] Testcase: test(AssertFalseExample): FAILED
[junit] AssertFalseExample
[junit] junit.framework.AssertionFailedError: Asse
[junit] at AssertFalseExample.test(Unknown Sou
[junit]
[junit]
[junit] Test AssertFalseExample FAILED
but if return false the program executed test case successfully. In this example build.xml file is used to compile, test and run the java file. The <property name="TALK" value ="true"/> is used to search path for source files, search path for class files, parsing the jar file, loading the all required classes and checking the class file. If <property name="TALK" value ="true"/> is not used in build.xml file then the output displays only [junit] Testsuite.
build.xml
<project name="JUnitTest" default="test" basedir=".">
|
Source code of AssertFalseExample.java
import junit.framework.*;
|
output: