aspose file tools
The moose likes Beginning Java and the fly likes junit test in general Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Reply Bookmark "junit test in general" Watch "junit test in general" New topic
Author

junit test in general

mike foulk
Greenhorn

Joined: Jul 12, 2006
Posts: 5
Need help with JUnit tests.
Can some one show me a few assert test examples, I'm so clueless with these things, like assertEquals, and assertNotNull.(please show me how in a beginner level example)

things I need to test now are: getting things With SQL and storing them into a collection and returning them.
Peter Chase
Ranch Hand

Joined: Oct 30, 2001
Posts: 1970
Why not STFW before asking?

I Googled for "junit test example" and got some good-looking articles on the first page. Searching for "junit test example SQL" revealed some DB-specific stuff.

Also, did you try www.junit.org ?


Betty Rubble? Well, I would go with Betty... but I'd be thinking of Wilma.<br /> <br />#:^P
Stan James
(instanceof Sidekick)
Ranch Hand

Joined: Jan 29, 2003
Posts: 8791
Here's a typical thing:

You can also give a comment that will be displayed on failure only:

The other assert methods are very similar. assertTrue takes a boolean and fails on false. assertNotNull takes any object and fails on null.

It's ok for test methods to throw exception. If an exception indicates an error just let it fly.

If you WANT the test subject to throw an exception:

STRONG RECOMMENDATION: The Bowling Game Kata is a great example of using JUnit at the center of the programming task. Look for whitepapers and tutorials at JUnit.org, too.


A good question is never answered. It is not a bolt to be tightened into place but a seed to be planted and to bear more seed toward the hope of greening the landscape of the idea. John Ciardi
 
I agree. Here's the link: http://ej-technologies/jprofiler - if it wasn't for jprofiler, we would need to run our stuff on 16 servers instead of 3.
 
subject: junit test in general
 
Similar Threads
JUnit tutorial for beginner
New to Junit
JUnit integration with EJB and Spring
JUnit Pocket Guide: future of JUnit?
How to run UT in Eclipse/Maven