testng-team/testng

@BeforeSuite and @AfterSuite notation

pierrehub2b opened this issue · 7 comments

TestNG Version

7.9.0

Expected behavior

no issue

Actual behavior

execution of test failed with following logs:
Native Injection is NOT supported for @BeforeSuite annotated beforeSuite.

Test case sample

create a test case with a 'beforeSuite' method like this:

	@BeforeSuite(alwaysRun = true)
	public void beforeSuite(ITestContext ctx) {
	}

this annotation was working in previous version of TestNG (from 6.13.1 to 7.8.0)

For a @BeforeSuite and @AfterSuite ITestContext ( this represents a <test> tag) is NOT relevant because if a <suite> tag contains 2 or more <test> tags, then which ITestContext object to inject becomes a question and also at a suite level, test level is not relevant because <test> tag is a child of the <suite> tag.

This was fixed as part of #2925

You can use Reporter.getCurrentTestResult() within your @BeforeSuite method and then work with it.

the problem is that this methods are not called anymore with 7.9.0.

@pierrehub2b - I didnt quite understand what you meant. Can you please clarify?

You can also refer to a similar issue that was recently closed with the same resolution #3029

This issue also has a sample that can be used.

when I launch a test execution with a java command line in debug mode, I have set a breakpoint with Eclipse int the method 'beforeSuite', the breakpoint is no more reached with the 7.9.0 version.
with 7.8.0 version I can see the execution reached the breakpoint

Have you tried setting up breakpoints to the sample that I had shared in the comments of #3029 ? Also maybe you need to also update the TestNG eclipse plugin ( I think it also went through with an update recently. Please correct me if I am wrong @missedone )

ok, it works now, I thaught we need to remove '(alwaysRun = true)' notation too with this last version.
Thanks for the example, it helps me to understand this evolution.

You can close this issue

Thank you for your time