I am using Selenium tool and Page Object Model. Currently each page has x number of test cases.
Eg. Login Page (Login Page elements) and LoginPageTest (corresponding validation in LoginPage used JUnit @Test
method)
Similarly I do have multiple pages.
But to run as a whole, it seems that this is not sufficient. I need to call all the @Test
methods in one class. If something fails, if I re-run that, then that only appears in the Junit result tab.
I don't need another one more class to contain all @Test
methods, since each validation class has @Test
methods. Is there any possibility to list down all the @Test
method in JUnit? Can I run whatever the method I want to run?
Assuming you are using JUnit 4 and your test methods are annotated with @Test
, select the @Test
annotation and look for its references by pressing Ctrl + Shift + G.
The Search view should be displayed with a list of classes that contain @Test
annotated methods. Then, in the Search view, click the Expand All button ( ) to show all the test methods
To run a particular test, rigth click on the test method signature (also works on the editor) and run it as a JUnit test.
If you prefer the shortcut, use Alt + Shift + X and then T. To debug, use Alt + Shift + D and then T.
You can run multiple test methods from a project, source folder or package. To do it, right click on the project, source folder or package and then run it as a JUnit test.
AFAIK, that's all you can do to display and run JUnit tests in Eclipse. If you are open to use IntelliJ IDEA, there are some cool features available out-of-the-box that you can use to find JUnit test methods.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With