Home Tutorials Javatesting JUnit Test 'assertFalse' Example Using Ant



JUnit Test 'assertFalse' Example Using Ant
Posted on: September 27, 2008 at 12:00 AM
This example illustrates about how to use the 'assertFalse' assertion method to test whether the class file executed test cases successfully or not.

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=".">

  <property name="testdir" location="test" />
  
  <path id="classpath.base"/>
  <path id="classpath.test">
  <pathelement location="${testdir}" />
  <path refid="classpath.base" />
  </path>

  <target name="clean" >
  <delete>
  <fileset dir="${testdir}" includes="**/*.class" />
  </delete>
  </target>

  <target name="compile" depends="clean">
  <javac srcdir="${testdir}" >
  <classpath refid="classpath.test"/>
  </javac>
  </target>

  <target name="test" depends="compile">
  <junit>
  <classpath refid="classpath.test" />
  <formatter type="brief" usefile="false" />
  <test name="AssertFalseExample" />
  </junit>
  </target>

</project>

Source code of AssertFalseExample.java

import junit.framework.*;

public class AssertFalseExample extends TestCase{

  public void test(){
  assertFalse( "AssertFalseExample"false );
  }
}

output:

Download Source Code

     

Related Tags for JUnit Test 'assertFalse' Example Using Ant:
cfileclassiomethodtestexecrtfthisexeassertcasecasexampleexecutetoexamsseeilsuccessnotlsuseulcenoasmouttrcaclesfullfalseasemehowrateratescutxaxampsxesuessatisllmplccstrtfrtssthstabpleplono


More Tutorials from this section

Ask Questions?    Discuss: JUnit Test 'assertFalse' Example Using Ant  

Post your Comment


Your Name (*) :
Your Email :
Subject (*):
Your Comment (*):
  Reload Image
 
 

Ask Questions?

If you are facing any programming issue, such as compilation errors or not able to find the code you are looking for.

Ask your questions, our development team will try to give answers to your questions.