File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Testing and the fly likes Am I doing unit test right? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of OCA/OCP Java SE 7 Programmer I & II Study Guide this week in the OCPJP forum!
JavaRanch » Java Forums » Engineering » Testing
Bookmark "Am I doing unit test right?" Watch "Am I doing unit test right?" New topic
Author

Am I doing unit test right?

Hussein Baghdadi
clojure forum advocate
Bartender

Joined: Nov 08, 2003
Posts: 3479

Hi.
I'm trying to adopt unit testing in my application.
Here my Ant task:

This target uses <batchtest> , so it will runs all the tests in this folder even I don't want to do so.
Suppose I have many tests, tests that connects to the database, tests for parsing XML and so on.
How to run a specific test file? or it is a best practice to run them all?
Thanks.
Lasse Koskela
author
Sheriff

Joined: Jan 23, 2002
Posts: 11962
    
    5
Originally posted by John Todd:
This target uses <batchtest> , so it will runs all the tests in this folder even I don't want to do so. Suppose I have many tests, tests that connects to the database, tests for parsing XML and so on. How to run a specific test file? or it is a best practice to run them all?

In a build script, one good practice is to always run all tests. Another good practice is to always run most tests (the fast ones) and run the rest (the slow ones) with a special target only when you feel that you're ready to check in your changes.

Typically, when I want to run just one test or all tests in one specific package, I do that from the IDE.


Author of Test Driven (2007) and Effective Unit Testing (2013) [Blog] [HowToAskQuestionsOnJavaRanch]
Jeanne Boyarsky
author & internet detective
Marshal

Joined: May 26, 2003
Posts: 30789
    
157

Originally posted by John Todd:
tests that connects to the database,

Noting that these aren't unit tests. Another practice is to run all the unit tests from the build machine (if a database isn't available) and run the integration tests on another machine.


[Blog] [JavaRanch FAQ] [How To Ask Questions The Smart Way] [Book Promos]
Blogging on Certs: SCEA Part 1, Part 2 & 3, Core Spring 3, OCAJP, OCPJP beta, TOGAF part 1 and part 2
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Am I doing unit test right?