Automation QA Testing Course Content

JUnit Interview Questions (Additional Information)

Q: What method can you call in your test method to automatically fail a test? A: fail(“error description here!”);

Q: You are testing a Dog class; to test a Dog object, you need to instantiate it before you can run tests on it. So you write a setUp() function to instantiate the Dog. You only want to run this function once during all of the testing. What must you put directly above the setUp() function signature so JUnit knows to run setUp() before running the tests? A: @BeforeClass (@BeforeAll in JUnit 5) Q: What must be the function signature of the setUp() function described above? A: public static void. Any function with @BeforeClass (@BeforeAll in JUnit 5) or @AfterClass (@AfterAll in JUnit 5) needs to be static. Q: You are done testing the Dog class. You write void tearDown() function which cleans up data and prints information to console after each test. You want this function to run after every single test. What must you put directly above the tearDown() function signature so JUnit knows to run tearDown() after running each test? A: @After (@AfterEach in JUnit 5)

No comments:

Post a Comment

Note: Only a member of this blog may post a comment.