If @beforeMethod or @afterMethod fails then all children of the same base class will be skipped
See original GitHub issueI’ve made an example to reproduce the issue: https://github.com/smaant/testng-bug-example
Description
Case#1 - normal behaviour
There’re two independent classes: Class1
and Class2
. Class1
has an @afterMethod
methods and for some reason it fails. All the rest method of the Class1
will be skipped in this case and Class2
will be executed as usual.
Case#2 - unexpected behaviour
There’re two classes: Class1
and Class2
and they have one common parent SuperClass
. Class1
has an @afterMethod
method and for some reason it fails. In this case the rest of the Class1
methods will be skipped AND (unexpected part) all methods of the Class2
will be skipped too.
In example I’ve added one more super class with one child to demonstrate it will be actually executed, because of another parent.
Issue Analytics
- State:
- Created 10 years ago
- Comments:9 (2 by maintainers)
Top Results From Across the Web
TestNG: All subsequent Test classes are skipped when ...
I need the @BeforeClass in the TestBase class to provide setup that all testclasses will need and I don't want to repeat in...
Read more >Combination of @BeforeClass and @BeforeMethod causes ...
When a @BeforeClass in a child class fails, and a @BeforeMethod exists in a base class shared with another class all end up...
Read more >BeforeMethod/@AfterMethod(onlyForGroups) methods did not ...
Its an interesting observation if you change onlyforgroups to groups then everything works: but when there are multiple groups included in ...
Read more >TestNG - Test LifeCycle Annotations - HowToDoInJava
Lifecycle Methods in Parent and Child Classes ... it belongs to, or even if one or more methods invoked previously failed or was...
Read more >TestNG
@BeforeMethod @AfterMethod, Configuration information for a TestNG class: @BeforeSuite: The annotated method will be run before all tests in this suite have ...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Problem with children being skipped when one child fails during its own @beforeClass method still holds, if children have @beforeClass and the parent class has @beforeClass AND @afterClass. When you remove @afterClass in parent class, everything works fine, no non-failing children are skipped.
@drkthng Could you add your test case in TestNG tests (or update them) in a PR? See the
test.inheritance
package.