I'm using Java and Selenium Webdriver, but there is something that I don't understand. Do I need to create separate classes for each test, or I just need to create one class and in that class have all my tests.
Can someone help me with this?
-
You might be interested in a discussion that I started yesterday on the same subject.EightyEight– EightyEight2016年01月25日 17:49:12 +00:00Commented Jan 25, 2016 at 17:49
1 Answer 1
(Unit)Test-runners wrap their tests in a class for execution. You can place multiple tests into a single class. Often an annotation is used to show the class method is a test. jUnit uses @Test
, MStest uses <TestMethod>
and nUnit uses [Test]
Personally I group tests that test the same part of the application into a single class. This way the class files do not become to big and I can add helper functions close to the tests.
Now you are thinking about how to structure your automated tests also be sure to read about the Page Object pattern. As it the current best practice in preventing code duplication in tests.
-
Great Niels! Thank you for your reply. I also talked about this with my manager and he also suggested that if the tests are dependant, then use a single class for those dependant tests. If the tests are independent, then use more classes and just add them to the executable xml that run all the tests.Laurenzanoster– Laurenzanoster2016年01月26日 19:38:11 +00:00Commented Jan 26, 2016 at 19:38