Programming Tutorials Browser Tutorials Articles Struts Tutorials Hibernate Tutorials

  Tutorial: Running Individual Test Cases from Ant

JUnit and Ant are indispensable tools for Java development. discusses how to use them together more effectively, allowing you more control over which test cases get run. We\'ll start by showing how to run a specific Test class from Ant, and then move on t

Tutorial Details:

Test-first design and Extreme Programming suggest that we should run all of the tests, all of the time. However, not everyone has the luxury of using the test-first approach. The techniques discussed in this article were developed to deal with writing test cases for an existing, completely untested system. In such a system, tests are often just used as an easier way to make sure code doesn\'t blow up, rather than testing it with the UI.

The main reason I have found for wanting to run only selected test cases is in the case of bug fixes. I\'ll write a test method (or three) to exercise the bug, and then run those test cases repeatedly as I work on the bug. In an untested system, tests rarely are completely self-verifying, so I\'ll need to look at the log output. Being able to look at the output from only one test case is helpful for debugging. Another reason for wanting to run only a few tests is that tests often take a long time to run. Running test cases in isolation from each other is also warranted because, as often as not, the problem causing a test to fail is in the test itself.

I certainly recommend running all of the tests on a regular basis. But if you are already modifying your Ant build or editing your source code in order to selectively run your tests, you may find that the techniques discussed in this article will help shorten your code-compile-test cycle, resulting in better productivity for you.

Ant installed and configured correctly so you can use the optional task. Test-first design and Extreme Programming suggest that we should run all of the tests, all of the time. However, not everyone has the luxury of using the test-first approach. The techniques discussed in this article were developed to deal with writing test cases for an existing, completely untested system. In such a system, tests are often just used as an easier way to make sure code doesn\'t blow up, rather than testing it with the UI.

The main reason I have found for wanting to run only selected test cases is in the case of bug fixes. I\'ll write a test method (or three) to exercise the bug, and then run those test cases repeatedly as I work on the bug. In an untested system, tests rarely are completely self-verifying, so I\'ll need to look at the log output. Being able to look at the output from only one test case is helpful for debugging. Another reason for wanting to run only a few tests is that tests often take a long time to run. Running test cases in isolation from each other is also warranted because, as often as not, the problem causing a test to fail is in the test itself.

I certainly recommend running all of the tests on a regular basis. But if you are already modifying your Ant build or editing your source code in order to selectively run your tests, you may find that the techniques discussed will help shorten your code-compile-test cycle, resulting in better productivity for you.

Ant installed and configured correctly so you can use the optional task.need to make sure junit.jar and optional.jar are in the ANT_HOME/lib directory of your Ant install


 

Read Tutorial at: Click here to view the tutorial

Rate Tutorial:
Running Individual Test Cases from Ant

View Tutorial:
Running Individual Test Cases from Ant

Related Tutorials:

Java Tip 70: Create objects from jar files! - JavaWorld - March 1999
Java Tip 70: Create objects from jar files! - JavaWorld - March 1999
 
One, two, three, or n tiers? - JavaWorld January 2000
One, two, three, or n tiers? - JavaWorld January 2000
 
Test infect your Enterprise JavaBeans - JavaWorld May 2000
Test infect your Enterprise JavaBeans - JavaWorld May 2000
 
JUnit best practices - JavaWorld December 2000
JUnit best practices - JavaWorld December 2000
 
Printing in Java, Part 4 - JavaWorld February 2001
Printing in Java, Part 4 - JavaWorld February 2001
 
Automate your build process using Java and Ant - JavaWorld October 2000
Automate your build process using Java and Ant - JavaWorld October 2000
 
Test networked code the easy way
Test networked code the easy way
 
Maven ties together tools for better code management
Maven ties together tools for better code management
 
Best tools for mobile application development
Best tools for mobile application development
 
Very interesting article
Very interesting article
 
Bug patrol
Bug patrol
 
Top 15 Ant Best Practices
Top 15 Ant Best Practices Ant, building and deploying Java applications required a hodgepodge of platform-specific scripts, makefiles, proprietary IDEs, or manual processes. Now, nearly every open source Java project uses Ant. A great number of companie
 
Flexible User and Environment Ant Configuration
Flexible User and Environment Ant Configuration The de facto standard for building, packaging, and deploying Java applications is Apache Ant. Small differences in developers\' environments or preferences may cause problems with some Ant tasks that invo
 
Introduction to Tag Unit
Getting Started For the purpose of this article, let's say that we would like to test the core taglib from the Jakarta Taglibs implementation of the JSTL, a taglib that many people will be aware of and have experience with. Assuming that you already have
 
Euler proof mechanism
Euler is an inference engine supporting logic based proofs of test cases (*).
 
A lightweight nonintrusive EJB testing framework
A lightweight nonintrusive EJB testing framework Summary This article presents a simple, easy-to-deploy framework that enables fine-grained tests to be run on the container, making it possible to develop and maintain Enterprise JavaBeans components usin
 
Mock Objects in Unit Tests
EasyMock is a well-known mock tool that can create a mock object for a given interface at runtime.
 
10 Minutes Guide to Ant
10 Minutes Guide to Ant 10 Minutes Guide to Ant Previous Tutorial Index Next Introduction Well for the next 10 minutes get ready to devote to the ant guide. This will make some sence to the ant. Ant is a free tool under GNU Licence and is
 
Building Web Application With Ant and Deploying on Jboss 3.0
Building Web Application With Ant and Deploying on Jboss 3.0 Building Web Application With Ant and Deploying on Jboss 3.0 Previous Tutorial Index Next In this lesson I will show you how to build you web application and install on the Jboss 3.0
 
developing a Session Bean and a Servlet and deploy the web application on JBoss 3.0
developing a Session Bean and a Servlet and deploy the web application on JBoss 3.0 Writing Stateless Session Bean and Calling through Servlet Previous Tutorial Index Next In this lesson I will show you how to develop a Stateless Session Bean and
 
Site navigation
 

 

Send your comments, Suggestions or Queries regarding this site at roseindia_net@yahoo.com.

Copyright © 2006. All rights reserved.