Exams Attended

Mock Exams

Make Homepage

Bookmark this page

Subscribe Email Address

JUnit Interview Questions and Answers

Ques. How To Write a Simple JUnit Test Class?
Ans. You should be able to write this simple test class with one test method:


import org.junit.*;

public class LoginTest

{

@Test public void testLogin()

{

String username = \"withoutbook\";

Assert.assertEquals(\"withoutbook\", username);

}

}


Here first argument in assertEquals is the known parameter which should be equal to username. If both are same it will send me true and if both are not equal sends me false.
Is it helpful? Yes No

Most helpful rated by users:

©2021 WithoutBook