In this video of code decode we have explained junit interview questions and answers for experienced with explaination
Udemy Course of Code Decode on Microservice k8s AWS CICD link:
https://openinapp.co/udemycourse
Course Description Video :
https://yt.openinapp.co/dmjvd
What is JUnit?
JUnit is the testing framework, it is used for unit testing (The process of testing individual functionality (known as a unit) of the application is called unit testing.) of Java code. Its done by writing java code that automatically invokes your unit code and test it.
JUnit = Java Code + Unit Testing
What annotations u used in JUnit?
@SpringBootTest - This annotation creates an application context and loads the full application context. which means we can @Autowire any bean that's picked up by component scanning into our test.
@Test : This annotation over a public method of void return type can be run as a test case. This is a replacement of the org.junit.TestCase annotation.
@Mock()
@InjectMocks
@Before: This is used when we want to execute the preconditions or any initialisation based statements before running every test case.
What annotations u used in JUnit?
@BeforeClass: This is used when we want to execute statements before all test cases. The statements may include test connections, common setup initialisation etc.
@After: This is used when we want to execute statements after each test case. The statements can be resetting the variables, deleting extra memory used etc.
@AfterClass: This is used when certain statements are required to be executed after all the test cases of the class are run. Releasing resource connections post-execution of test cases is one such example.
@Ignores: This is used when some statements are required to be ignored during the execution of test cases.
@Test(expected=NullPointerException.class): This is used when some exception thrown by the target method needs to be asserted.
What is Mockito in JUnit?
Mockito is a Java-based mocking framework used for unit testing of Java application. Its used in conjunction with other testing frameworks such as JUnit and TestNG. It internally uses Java Reflection API and allows to create objects of a service.
Most Asked Core Java Interview Questions and Answers : • Core Java frequently asked Interview Quest...
Advance Java Interview Questions and Answers : • Advance Java Interview Questions
Java 8 Interview Questions and Answers : • Java 8 Interview Questions(New Features)
Hibernate Interview Questions and Answers : • Hibernate Interview Questions Java
Spring Boot Interview Questions and Answers : • Advance Java Interview Questions
Angular Playlist : • Angular Course Introduction || Angular 8
SQL Playlist : • SQL Interview Questions and Answers
GIT : • GIT
Subscriber and Follow Code Decode
Subscriber Code Decode : https://www.youtube.com/c/CodeDecode?...
LinkedIn : / codedecodeyoutube
Instagram : / codedecode25
#singletondoublecheckedlocking #codedecode #javainterviewquestion