Featured

Junit testing Interview Questions with tutorial in Spring boot Java | Code Decode | Part -1



Published
In this video of code decode we have explained junit interview questions and answers for experienced with explaination

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 : https://youtube.com/playlist?list=PLyHJZXNdCXscoyL5XEZoHHZ86_6h3GWE1

Advance Java Interview Questions and Answers : https://youtube.com/playlist?list=PLyHJZXNdCXsexOO1VQ4vs-BM2-8CKrixd

Java 8 Interview Questions and Answers : https://youtube.com/playlist?list=PLyHJZXNdCXsdeusn4OM33415DCMQ6sUKy

Hibernate Interview Questions and Answers : https://youtube.com/playlist?list=PLyHJZXNdCXsdC-p2186C6NO4FpadnCC_q

Spring Boot Interview Questions and Answers : https://youtube.com/playlist?list=PLyHJZXNdCXsexOO1VQ4vs-BM2-8CKrixd

Angular Playlist : https://www.youtube.com/watch?v=CAl7RQSdq2Q&list=PLyHJZXNdCXsfxRtDwtGkDD_lLfTWc1g0i


SQL Playlist : https://www.youtube.com/playlist?list=PLyHJZXNdCXse86eLuwy5uZohd_bddE9Ni

GIT : https://youtube.com/playlist?list=PLyHJZXNdCXscpl6pxOnL2lRWJlzvzjyZE

Subscriber and Follow Code Decode
Subscriber Code Decode : https://www.youtube.com/c/CodeDecode?sub_confirmation=1
LinkedIn : https://www.linkedin.com/in/codedecodeyoutube/
Instagram : https://www.instagram.com/codedecode25/

#singletondoublecheckedlocking #codedecode #javainterviewquestion
Category
Job
Be the first to comment