1.

How can a method be made to run before the execution of every test case?(a) Annotate the method with @Before(b) Prefix the method name with startfirst(c) Annotate the method with a @BeforeClass(d) Such a method cannot be madeI have been asked this question in an interview.My enquiry is from Running Parameterized Tests in portion Exploring Core JUnit of JUnit

Answer»

Correct OPTION is (a) Annotate the method with @Before

The best EXPLANATION: Annotating a method with @Before IMPLIES that method to be run before the every test method. The @Before METHODS of superclasses are run before those of the current CLASS.



Discussion

No Comment Found

Related InterviewSolutions