• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Tim Cooke
  • Campbell Ritchie
  • Ron McLeod
  • Liutauras Vilda
  • Jeanne Boyarsky
Sheriffs:
  • Junilu Lacar
  • Rob Spoor
  • Paul Clapham
Saloon Keepers:
  • Tim Holloway
  • Tim Moores
  • Jesse Silverman
  • Stephan van Hulst
  • Carey Brown
Bartenders:
  • Al Hobbs
  • Piet Souris
  • Frits Walraven

JUnit Testing - for a complete Java Project.

 
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hallo Everybody,

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.



Sreenivas Mangasandra.
 
author
Posts: 11962
5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
author
Posts: 113
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

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.
 
Lasse Koskela
author
Posts: 11962
5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

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...
 
Jared Richardson
author
Posts: 113
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Michael Feathers blogged on the topic this week.

A Set of Unit Testing Rules
 
reply
    Bookmark Topic Watch Topic
  • New Topic