Skip to content
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

Restore testnames when using suites in suite. #2712

Merged
merged 1 commit into from Jan 17, 2022

Conversation

martinaldrin
Copy link

@martinaldrin martinaldrin commented Jan 12, 2022

Fixes #2709.

Did you remember to?

  • Add test case(s)
  • Update CHANGES.txt
  • Auto applied styling via ./gradlew autostyleApply

We encourage pull requests that:

  • Add new features to TestNG (or)
  • Fix bugs in TestNG

If your pull request involves fixing SonarQube issues then we would suggest that you please discuss this with the
TestNG-dev before you spend time working on it.

Note: For more information on contribution guidelines please make sure you refer our Contributing section for detailed set of steps.

@martinaldrin martinaldrin force-pushed the testnames branch 2 times, most recently from 7ae2eae to 3726a06 Compare January 12, 2022 12:12
@bj-9527
Copy link
Contributor

bj-9527 commented Jan 13, 2022

Hi Martin,

I think you also need to add some info in changes.txt.

@martinaldrin
Copy link
Author

Hi Martin,

I think you also need to add some info in changes.txt.

thanks, done

@martinaldrin
Copy link
Author

martinaldrin commented Jan 13, 2022

@krmahadevan please review when you have time.
I also have a question, if I understand now Java 11 is mandatory for next release, or will it be possible deliver patches on 7.5?

@juherr juherr linked an issue Jan 13, 2022 that may be closed by this pull request
7 tasks
Copy link
Member

@krmahadevan krmahadevan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I haven't quite understood the scenario wherein this doesn't work. Can we please help add a unit test for this which explicitly tests out the fix (am guessing that there's no test right now for this which is why the build was passing even though this functionality was broken)

@martinaldrin
Copy link
Author

martinaldrin commented Jan 14, 2022

I haven't quite understood the scenario wherein this doesn't work. Can we please help add a unit test for this which explicitly tests out the fix (am guessing that there's no test right now for this which is why the build was passing even though this functionality was broken)

The problem occurs when we defined suites in suites as below, then it requires the test names to exist in all subsuites, after the bug that was introduced in TestNg 7.5. but we define several testnames that can exist in any of the subsuites and only the matching tests should be exuecuted.

DOCTYPE suite SYSTEM "http://testng.org/testng-1.0.dtd" >
<suite name="testsuite">
    <suite-files>
        <suite-file path="./subsuite1.xml" />
        <suite-file path="./subsuite2.xml" />
        <suite-file path="./../startrestart/subsuite3.xml" />
    </suite-files>
</suite>

Regarding the unit test, I will try to add one, but I did not find any unit test for the class TestNg

@martinaldrin
Copy link
Author

I haven't quite understood the scenario wherein this doesn't work. Can we please help add a unit test for this which explicitly tests out the fix (am guessing that there's no test right now for this which is why the build was passing even though this functionality was broken)

I added a unit test in JarFileUtilsTest.java, since I was able to reuse allot of code for a similar test.
I managed to reproduce the fault by adding back the old method.

testNg.setTestNames(Arrays.asList(expectedTestNames));
testNg.setXmlPathInJar(jar.getAbsolutePath());
testNg.setTestJar(jar.getAbsolutePath());
testNg.initializeSuitesAndJarFile();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@martinaldrin - I dont see any assertions. Was that intentional ?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, The purpose of the test is to ensure that a exception is not thrown. I can not add any assert methods.
We just ensure that the method do not check suites in jarfiles here, because that is handled later in JarFileUtiles.
And JarFileUtiles already have unit tests to ensure that this is working as expected, the problem started to aggregate suites in the jarfile here without consider sub suites.

A very similar method exist in class: JarFileUtil method: testngXmlExistsInJar that take care of that part.

@martinaldrin martinaldrin force-pushed the testnames branch 2 times, most recently from 1eb708d to 43f9b2e Compare January 14, 2022 15:14
@juherr juherr merged commit 2091b13 into testng-team:master Jan 17, 2022
@juherr
Copy link
Member

juherr commented Jan 17, 2022

Thank for the change! 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Testnames not working together with suites in suite
6 participants