TECHNICALFACILITATION.COM - THE ULTIMATE WEBSPHERE AND JAVA CERTIFICATION GUIDES AND RESOURCES
Google
Download the Completed Solution: 04JavaBeanJUnit.ear.

The junit.jar file must be on your classpath for you to bring this ear file in and have the JUnit tests compile - just so you know.

Scroll to the bottom of the page for pertinent code snippets.

Running JUnit Test on JavaBeans

This free, multimedia tutorial shows you how to use IBM's Rational Application Developer (IRAD) 6.0 to create and run a JUnit test on a simple JavaBean.

If you found something helpful here, please do your part and help support the site. Link to us, buy some books, support our sponsors, tell your developer friends about us, and remember: Happy Java!


package com.examscam.common.test;

import com.examscam.common.Timer;

import junit.framework.TestCase;





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());
}
}

Google
THE ULTIMATE CERTIFICATION AND WEBSPHERE RESOURCES - BUY THEM NOW ON AMAZON
eXTReMe Tracker