JUnit Question:
Download Job Interview Questions and Answers PDF
Why Does Poeple Import org.junit.Assert Statically?
Answer:
Poeple use the static import statement on org.junit.Assert to save coding time on calling its assetion methods. With a normal import statement, assertion method names must qualified with the class name like this:
import org.junit.Assert;
...
Assert.assertEquals(12, message.length());
With a static import statement, assertion method names can be used directly like this:
import static org.junit.Assert.*;
...
assertEquals(12, message.length());
import org.junit.Assert;
...
Assert.assertEquals(12, message.length());
With a static import statement, assertion method names can be used directly like this:
import static org.junit.Assert.*;
...
assertEquals(12, message.length());
Download JUnit Interview Questions And Answers
PDF
Previous Question | Next Question |
Can You Provide a List of Assertion Methods Supported by JUnit 4.4? | What Is the @SuiteClasses Annotation? |