Giter Club home page Giter Club logo

Comments (6)

rjmartell avatar rjmartell commented on July 24, 2024

One disadvantage of the suggested approach is that the precondition tests must be associated with a <test> tag (conformance class). That is, each precondition may be run (unnecessarily) multiple times rather than just once at the beginning of the test run. It might be better to add the preconditions to a mandatory conformance class and set a flag which is then read to determine whether other conformance classes are run or skipped.

from ets-wfs20.

bermud avatar bermud commented on July 24, 2024

Maybe call it: preconditions conformance class.

from ets-wfs20.

rjmartell avatar rjmartell commented on July 24, 2024

That would be one approach, but the problem of signalling an unsatisfied precondition between conformance classes remains. Since there is always at least one mandatory conformance class, including the preconditions there makes sense. For example:

<test name="Conformance Level 1">
    <packages>
      <package name="org.opengis.cite.abc10.level1" />
    </packages>
    <classes>
      <class name="org.opengis.cite.abc10.SuitePreconditions" />
    </classes>
  </test>

If a test method in SuitePreconditions detects that a precondition is not satisfied, then a suite attribute is set like so:

testContext.getSuite().setAttribute("preconditions-ok", Boolean.FALSE);

A @BeforeTest method defined for some other conformance class can then check the suite attribute:

Boolean preconditionsOk = (Boolean) testContext.getSuite().getAttribute("preconditions-ok");
Assert.assertTrue(preconditionsOk, "One or more test suite preconditions not satisfied.");

All tests in this conformance class are skipped if any precondition was not satisfied, and the failing test in the mandatory conformance class will indicate what the problem was.

Note: In the test suite definition, the suite/@configfailurepolicy attribute must have the value "skip".

from ets-wfs20.

bermud avatar bermud commented on July 24, 2024

Maybe, instead of packaging the preconditions as a conformance class, make them part of the most basic mandatory conformance class.

from ets-wfs20.

rjmartell avatar rjmartell commented on July 24, 2024

The advantage of breaking out the preconditions into a separate <test> group is to make them more visible in the report. And it emphasizes that these checks do not actually correspond to a conformance class defined in some base specification.

<test name="Preconditions">
    <classes>
        <class name="org.example.testng.demo.SuitePreconditions"/>
    </classes>
</test>

If a precondition is not satisfied, it is added to the value of the "failed-preconditions" attribute, and this is checked in subsequent BeforeTest methods in other conformance classes.

@BeforeTest
public void checkPreconditions(ITestContext context) {
    Object failedPreconditions = context.getSuite().getAttribute("failed-preconditions");
    if (null != failedPreconditions) {
        throw new SkipException("One or more preconditions not satisfied: " + failedPreconditions);
    }
}

The preconditions--and their descriptions--become much more visible in the report, thus eliminating a potential source of confusion regarding skipped tests.

preconditions

from ets-wfs20.

bermud avatar bermud commented on July 24, 2024

How can differentiate these "Preconditions" from a conformance class. Both from a user interface point of view and a program parsing the results?

from ets-wfs20.

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.