Let us have the following TestNG tests:
@Test
public void Test1() {
}
@Test (dependsOnMethods={"Test1"})
public void Test2() {
}
@Test (dependsOnMethods={"Test2"})
public void Test3() {
}
Tests serves as functional end to end webui tests (with Selenium Webdriver). Each test method is a step in context of long e2e scenario.
How can we refactor the tests to make them more readable? The best solution may be to remove all this 'dependsOnMethods' parameters in annotation and provide this 'dependsOnMethods' functionality implicitly. The question is How? Expectations in priority order:
given "user is logged in and sets expert mode", {
//... setup, a la @BeforeClass
}
then "user can enable bla bla bla" {
//...
}
then "user can check poo poo poo" {
//...
}
then "user save changes" {
//...
}
then "user revert changes", {
// Tear Down, a la @AfterClass
}
Is there any problems with 'just starting to write your other test classes in groovy in the same java project'?
One of crazy solution may be - broke everything and move to Thucydides. But this is not an option in my case.
PS I know dependent tests is a 'bad practice'. But I believe that 'testing dependencies itself' is also a good point in automation...
Yes.. there is an alternative to using depends on... DONT DO IT!
As i've answered here...
This is terrible test logic.. As an experienced professional software test engineer.. I advise you to immediately disperse from this automation path that you are on.
Good test architecture requires that each method be SELF-SUFFICIENT and should not depend on other tests to complete before continuing. Why? Because say Test 2 depends on Test 1. Say Test 1 fails.. Now Test 2 will fail.. eventually, you'll have Test 1,2,3,4,5 tests failing, and you don't even know what the cause was.
My recommendation to you sir would be to create self-sufficient, maintainable, and short tests.
This is a great read which will help you in your endeavours: http://www.lw-tech.com/q1/ug_concepts.htm
Keep TestNG, but involve any other instrument, eg easyb? using groovy instead of java... Can I use TestNG groups with easyb? Is it possible, to easyb not in bdd style but 'junit' style
This is the choice I Used.
You will have no testng like groups with easyb (at least out of the box), and I didn't find so far any way to 'anotate' easyb/groovy 'test methods'.
But, now I have:
This is how tests can look:
beforeAllSetup()
before "each method setup", {
//implementation
}
after "each method tear down", {
//...
}
it "first test this", {
//...
}
it "this will be shown as pending in the report", /*{
//...
}*/
it "then test this", {
//...
}
afterAllTearDown()
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.