Can You Write a JUnit 3.8 Test Class Template in 2 Minutes?
JUnit Questions and Answers
(Continued from previous question...)
Can You Write a JUnit 3.8 Test Class Template in 2 Minutes?
Writing JUnit 3.8 test class template is not that hard. You should be able to do it within 2 minutes.
Here is a nice sample template:
import junit.framework.TestCase;
public class JUnit38Test extends TestCase {
private java.util.List emptyList;
/**
* Sets up the test fixture.
* (Called before every test case method.)
*/
public void setUp() {
emptyList = new java.util.ArrayList();
}
/**
* Tears down the test fixture.
* (Called after every test case method.)
*/
public void tearDown() {
emptyList = null;
}
public void testSomeBehavior() {
assertEquals("Empty list should have 0 elements",
0, emptyList.size());
}
}
(Continued on next question...)
Other Interview Questions
|