Coder Social home page Coder Social logo

Comments (8)

nullin avatar nullin commented on June 26, 2024

The problem is actually not in org.testng.reporters.XMLReporter but in SuiteRunner.runTest():

  private void runTest(TestRunner tr) {
    tr.run();

    ISuiteResult sr = new SuiteResult(m_suite, tr);
    m_suiteResults.put(tr.getName(), sr);
  }

The result is of TestRunner execution is added to m_suiteResults using test name as key, which is incorrect because TestNG doesn't enforce against having multiple tests with same name within a single suite.

Solution:

  1. When reading the XML suite, only create a single XmlTest for multiple tests with same name? This might not work because user might specify different set of parameters with different tests.
  2. Start enforcing that tests within same suite will have unique names. This has potential of breaking existing tests for many people.
  3. Append random character or something like "_1" at end of test name if m_suiteResults.get(testName) returns non-null value. Not sure how this will go down with folks when it comes down to comparing input xmls and outputs from reporters and listeners
  4. Implement something where TestRunners can be merged ???

What do you suggest Cedric?

from testng.

cbeust avatar cbeust commented on June 26, 2024

I also thought about all these options and neither is really straightforward. The best place to do this is as far up stream as possible, i.e. 1), but the XML parsing needs to be updated in several places (because of all the m_current*** fields I am maintaining because of SAX).

from testng.

nullin avatar nullin commented on June 26, 2024

unless you see a real need for having multiple test tags with same name, we should maybe break the backward compatibility in this case by going with option 2. It's the cleanest and simplest solution. I don't see a lot of people running into this issue, otherwise it would have been reported earlier.

Otherwise, If you do go with option 1, won't you run into the issue with different set of parameters defined for different tests. How do you think that would be handled?

from testng.

cbeust avatar cbeust commented on June 26, 2024

Well, it's already undefined behavior so we wouldn't make things much worse, but yes, maybe we should just catch this in ContentTestNGHandler and abort if we detect two tags with the same name.

from testng.

nullin avatar nullin commented on June 26, 2024

ok. I'll make the change.

from testng.

cbeust avatar cbeust commented on June 26, 2024

Actually, a correction: we should catch this slightly higher than at XML parsing so that the fix will catch this both in XML and YAML documents.

from testng.

nullin avatar nullin commented on June 26, 2024

Should be fixed with nullin@7f570c9.

Opening a pull request now.

from testng.

JIGD avatar JIGD commented on June 26, 2024

I think this issue should be closed too.

from testng.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.