-
Notifications
You must be signed in to change notification settings - Fork 1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
@BeforeTest/@BeforeSuite in superclass only invoked on first instance that inherits from it. #313
Comments
I already reported it 10 months (!) ago #184. |
As i can see from code this behavior is by-design: Also using IMHO: Nice solution for that problem is generating implementation of |
- Only set static variables from LdpTest setup. Setup is only called once even when several classes inherit from LdpTest. - Change setup and tear down method names so we don't accidentally override them in subclasses. See testng-team/testng#313 Fixes w3c#192
- Only set static variables from LdpTest setup. Setup is only called once even when several classes inherit from LdpTest. - Change setup and tear down method names so we don't accidentally override them in subclasses. See testng-team/testng#313 Fixes w3c#192
@DurgaManickam Please, could you ask it on StackOverflow or the mailing list first? |
@juherr - I this we can close this issue. WDYT ? |
It works as expected: a before suite method is only called once by suite, even if it is located in a superclass. |
any conclusion fix for this issue ?
|
@abdulrazak-mumms Could you open a new issue and include a sample which reproduces the issue? |
I noticed that a @BeforeTest/@BeforeSuite method defined in as superclass of a test will only be executed once on the first instance of the inheriting classes.
As the documentation on the test annotations is a little sparse sometimes, it is not clear to me if this should be considered as bug or as feature.
If the @BeforeTest/@BeforeSuite method is executed on every inheriting class it might lose some of its semantics and act like a method annotated with @BeforeClass, which might not be the perfect solution in my eyes.
The other way would be to clearly document this not immediately obvious behavior and use the test context (ITestContext) to provide Test-scoped configuration and instance data to running tests.
This could be a possible solution:
A small project demonstrating the behavior and my current solution is here: https://github.com/jabbrwcky/testng-annotation-demo
/Jens
The text was updated successfully, but these errors were encountered: