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:
- Who Should Use JUnit?
- What is JUnit?
- How To Compile a JUnit Test Class?
- Why Do You Use JUnit to Test Your Code?
- How To Write a Simple JUnit Test Class?