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?
Software Quality Assurance & Testing Stack Exchange is a question and answer site for software quality control experts, automation engineers, and software testers. It only takes a minute to sign up.
Sign up to join this communityI'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?
(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.