SDET: JUnit interview questions for automation engineer

Carvia Tech | October 26, 2019 | 2 min read | 172 views


In this article we will cover important interview questions around Junit 4 and Junit 5 for every automation SDET engineer.

  1. How will you write a basic test case using JUnit

  2. Why do you write Unit tests in isolation?

  3. Can we only write unit tests using JUnit and not the integration tests?

  4. How does Junit compares with TestNG and other frameworks like BDD/Cucumber/etc?

  5. How will you group Junit 5 testcases based on functionality or other parameters?

  6. How to create custom Junit 5 meta annotation for a Tag

  7. How to programmatically run Junit 5 testcases for a specific Tag/Class/Package using Java/Kotlin code?

  8. How to make certain testcase run on a specific environment/machine/os only, skip otherwise?

  9. How to write integration testcase using Junit 5?

  10. How to write API testcases using Junit 5?

  11. How to specify order of execution for testcases? Should’d testcase be written in such a way that they can be run independent of execution order?

  12. How to write dynamic testcase in Junit 5? Write dynamic testcases for asserting recently developed palindrome function.

  13. What are parameterized tests in Junit 5? How to write a simple Parameterized test? When to use parameterized tests?

  14. How will you compare parameterized tests with dynamic tests?

  15. Write a simple Junit 5 testcase that checks a REST API for unauthorized access?

  16. What are advantages of using JUnit 5 over JUnit 4

  17. Explain Mike Cohn’s test pyramid

  18. Hemcrest matchers introduction

  19. AssertJ introduction

  20. How will you write a junit testcase that checks if the given exception was thrown with provided message

  21. What is difference between Assertions and Assumptions in Junit?

  22. How will you enable certain Junit 5 testcase only on certain Operating System?

  23. How to enable certain Junit Jupiter tests only on System Property Conditions

  24. How to enable certain Junit Jupiter tests based on environment variable condition?

Advanced Junit Concepts

  1. How to write a custom test execution listener that sends email for failures

  2. Parameterized testcase that reads test cases from CSV file

  3. What are data driven testcase, how to write them using JUnit 5

  4. Write a test case that loads data from CSV input

REST API Testing

  1. How to handle OAuth2 login using JUnit based tests

  2. What are different libraries for API testing? HttpClient, RestTemplate, WebClient, WebTestClient, RestAssured, how do you compare them?

  3. What is difference between RestAssured and Spring RestTemplate from testing perspective?

  4. How will you assert the value of a specific node in JSON returned by an API

  5. What are Contract Driven Tests? When will you use them?

  6. How will you write a testcase to assert that unauthorized user is not allowed to access a specific API


Top articles in this category:
  1. SDET: Rest Assured Interview Questions
  2. Top 50 SDET Java Programming Interview Questions & Answers
  3. Top 15 coding problems for SDET Java Interviews
  4. How to reverse a number in Java
  5. Junit 5 Platform Launcher API
  6. SDET Java Role - Essential Skills
  7. Write a program to reverse a string using recursion in Java


Find more on this topic:
SDET Interviews image
SDET Interviews

SDET Java Interview pattern and collection of questions covering SDET coding challenges, automation testing concepts, functional, api, integration, performance and security testing, junit5, testng, jmeter, selenium and rest assured

Last updated 1 week ago


Recommended books for interview preparation:

This website uses cookies to ensure you get the best experience on our website. more info