Prepare Interview

Mock Exams

Make Homepage

Bookmark this page

Subscribe Email Address

JUnit%20Interview%20Questions%20and%20Answers

Question: How To Write a Simple JUnit Test Class?
Answer: 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:

©2024 WithoutBook