Interview Questions

How To Wirte a Simple JUnit Test Class?

JUnit Questions and Answers


(Continued from previous question...)

How To Wirte a Simple JUnit Test Class?

This is a common test in a job interview. You should be able to write this simple test class with one test method:

import org.junit.*; 
// by FYICenter.com
public class HelloTest { 
    @Test public void testHello() {
        String message = "Hello World!";
        Assert.assertEquals(12, message.length());
    }
}

(Continued on next question...)

Other Interview Questions