Re: junit fail/error
Here's a free tutorial that shows you how to develop and run JUnit
tests:
http://www.technicalfacilitation.com/examscam/tf/get.php?link=web
In this example, I create on test that fails, one that errors out
(exception) and one that succeeds, just so you see how JUnit works.
And yes, an exception will rate as an error,not a failure.
Enjoy!
-Cameron McKenzie
Author of What is WebSphere?
All about WebSphere: www.pulpjava.com
Free WebSphere Tutorials: www.mcnz.com
Free SCJA Mock Certification Exams: www.scja.com
www.technicalfacilitation.com www.cameronmckenzie.com
public class TimerTest extends TestCase {
Timer t;
protected void setUp() throws Exception {
super.setUp();
t = new Timer();
t.start();
}
protected void tearDown() throws Exception {
super.tearDown();
t = null;
}
public void testStart() {
assertTrue("Timer isn't staring properly.",
t.getStartTime() <= System.currentTimeMillis());
}
public void testGetElapsedTime() {
assertTrue("Time Travel is not allowed", t.getElapsedTime() >= 0);
}
public void testReset() {
long originalStartTime = t.getStartTime();
t.reset();
assertTrue("Problem with reset", originalStartTime <=
t.getStartTime());
}
}
Petterson Mikael wrote:
Hi,
Is it correct that an error is a test that is not working and a failure
is a test that breaks du to code problem?
cheers,
//mikael