-
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
before configuration and before invocation should be 'SKIP' when beforeMethod is 'skip' #2880
Comments
@bobshie -Please include a sample (preferably a sample project) that can be used to reproduce the problem |
@krmahadevan , Thanks, I add an example and there is conflict with: it should be the same status in before invocation of 'beforeMethod' and 'issueTest'
|
Hi @krmahadevan , in order to simply reproduce this problem, I did some simple code and drew a flow of the issue that is being discussed now: If there are three methods: @BeforeClass
public void beforeClass() {
int i = 5/0; //throw an exception
}
@BeforeMethod
public void beforeMethod() {
}
@Test
public void issueTest() {
System.out.println("Test BeforeConfiguration behavior");
} And a customized listener: public class DemoListener implements IInvokedMethodListener, IConfigurationListener,ITestListener {
@Override
public void beforeConfiguration(ITestResult testResult) {
System.out.println(
"before configuration executed, method:" + testResult.getMethod().getMethodName() + ",testResultStatus:"
+ testResult.getStatus());
}
@Override
public void beforeInvocation(IInvokedMethod method, ITestResult testResult) {
System.out.println(
"before invocation executed, method:" + testResult.getMethod().getMethodName() + ",testResultStatus:"
+ testResult.getStatus());
}
@Override
public void onConfigurationSkip(ITestResult testResult, ITestNGMethod method) {
System.out.println("Skip Config Method," + testResult.getMethod().getMethodName() + ",testResultStatus:"
+ testResult.getStatus());
}
@Override
public void onTestStart(ITestResult testResult) {
System.out.println("OnTestStart Status:" + testResult.getMethod().getMethodName() + ",testResultStatus:"
+ testResult.getStatus());
}
} The execution process is performed as shown in the figure: In my opinion,since a config method(just like beforeMethod in this demo) has been determined to be skipped, the status obtained in beforeConfiguration() and beforeInvocation() for config method should be skip. In this way, config method and @test method are consistent. And I also found a phenomenon in which @OnTestStart and beforeInvocation for @test method also behave inconsistently. I’m not sure if TestNg’s definition of these two methods is different. As you know, since this issue was solved: #2729. If there is a situation in the demo, beforeConfiguration() will also be invoked, and we will get the status as STARTED, which will add a lot of changes for our project. |
@Hkh9966 - Since you have spent time on analysing this, would you be willing to help fix it by raising a PR? |
@krmahadevan , I'll try to do it. Can we fix it as: |
If we can change it to: For "onTestStart & beforeInvocation should be 'SKIP' when test method is 'SKIP'", it may be that the changes will be large. And I'm not sure if this change is justified. |
In that case, can we please file do the following ?
|
@krmahadevan , I think there is clear description in this thread, we only need to change the first one: about the next issue, testng has onTestStart() and onTestSkip() when test method is skipped:
so we can't change I can just fix the first one if it's agreed. |
@krmahadevan I agree with you. |
Signed-off-by: Bob Shi <bob.shi@ericsson.com>
Closes #2880 Ensure that before configuration and before invocation should be 'SKIP' when beforeMethod is 'skip'
TestNG Version
Expected behavior
Actual behavior
Is the issue reproducible on runner?
Test case sample
Contribution guidelines
Incase you plan to raise a pull request to fix this issue, please make sure you refer our Contributing section for detailed set of steps.
Description
After one of our test project uplift TestNG from 7.5 to 7.6 version, there are some unexpected behavior from before. the related issue is:
beforeConfiguration() listener method should be invoked for skipped configurations as well · Issue #2729 · cbeust/testng · GitHub
The text was updated successfully, but these errors were encountered: