-
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
Weird @BeforeMethod and @AfterMethod behaviour with dependsOnMethods #550
Comments
Maybe the solution would be to remove "dependsOnMethods" on after-/beforeMethod-annotations? Or to limit the type of "before"-methods to have the BeforeMethod-annotation (which sounds more natural to me) |
The idea is runs some specific setup/teardown operation before and after specific test method. This is the reason why i want to use this mechanism. |
Would it be possible to create two separated test-classes for this? |
Thank you for your comments but in this point of view TestNG developers should update documentation - probably @Before_/@After_ annotation attributes (remove dependsOnMethod from attributes). You are right i can do that, but i want to group my test methods from logical point of view to the classes, next level is packages. Regarding calling setup and tear down inside test method it is really not good concept. Especially for tear down - i.e. when test fails in exception in test logic i will loose possibility to clean it up. |
I think mbocek is correct, to me this behavior is wrong. Either moving the test to a separate class or removing the parameter from the annotation both feel like patchy, kludgy solutions. |
+1 @mbocek |
1 similar comment
+1 @mbocek |
@juherr - What do you think the behaviour here should be? I can alter the implementation to throw an error that looks like below (for the same example test that is shared in this bug):
|
To achieve this, you can do something like below (My bad that this response is coming nearly 8 years after you mentioned the problem :) ) You can add |
@krmahadevan the exception message you propose is clearly better. A similar check could be done for all methods that depend on methods of another type: test methods can only depend on test methods, but beforemethod can only depend on beforemethod too. |
Yes, this goes without saying. There would be edit checks for each of the configurations that would validate the following:
|
Sample code:
Result:
Regarding documentation:
My expectation was that the before and after method will be run only before and after test() method.
Please can you provide some fix or explanation.
Thank you.
The text was updated successfully, but these errors were encountered: