This week's book giveaway is in the General Computing forum. We're giving away four copies of Arduino in Action and have Martin Evans, Joshua Noble, and Jordan Hochenbaum on-line! See this thread for details.
I am new to JUnit and i have tried testing the sample testcases given with JUnit from Ant.
How can one apply Test cases for a complete project, i.e. a set of java source files, is it like i have to include a source directory in JUnit or how ?
what i understood till now is:
1. A build.xml file is used to execute test using Ant. 2. *Test.java with classes of them. 3. JUnit jar files.
So would that mean for me to test a project (set of java files) i need to write seperate *Test.java files to test them or can we just have one common component for any project.
It would be nice if any one can clear my question with an example. Thanks.
JUnit tests are unit tests. That means that each of your JUnit classes (classes that extend junit.framework.TestCase) is generally responsible for testing one class and one class only.
For example, let's say I have a small application that consists of three classes: Square, Circle, and Triangle. For these classes, I might have written test classes named TestSquare, TestCircle, TestTriangle, TestResizingTriangle, TestSkewingSquare, and so forth. Most of the time, it's one test class per one production class, but not always. Sometimes it just makes sense to split your unit tests for a given class into separate source files because they're testing different aspects of the production code.
Originally posted by Lasse Koskela: [QB]JUnit tests are unit tests. That means that each of your JUnit classes (classes that extend junit.framework.TestCase) is generally responsible for testing one class and one class only.
QB]
Don't forget that you can use the JUnit testing framework to do much more than just unit testing though. We use it for unit testing, functional testing as well as integration testing.
The same attributes that make it attractive for unit testing (lightweight, portable, fast) also make it great uppper level testing framework as well.
Check out <b>Ship It! A Practical Guide to Shipping Software</b><br /> <br /><a href="http://www.pragmaticprogrammer.com/titles/prj/" target="_blank" rel="nofollow">http://www.pragmaticprogrammer.com/titles/prj/</a>
Lasse Koskela
author
Sheriff
Joined: Jan 23, 2002
Posts: 11962
5
posted
0
Originally posted by Jared Richardson: Don't forget that you can use the JUnit testing framework to do much more than just unit testing though. We use it for unit testing, functional testing as well as integration testing.
That's true. We're also using JUnit for our integration tests. Yet, sometimes it would somehow seem better from a learning perspective to not be able to do that--just so that people realize that there's a difference between unit tests and integration tests even though they're both written as JUnit test cases...