Best way to write tests where one test depends on the output of another

197 vues
Accéder directement au premier message non lu

Ulrich Palha

non lue,
28 déc. 2011, 12:12:0428/12/2011
à testng-users
I first posted this on StackOverflow
http://stackoverflow.com/questions/8609516/best-way-to-write-testng-tests-where-one-test-depends-on-the-output-of-another,
where Cedric suggested I try here and post some code too.

Summary
I have several webservices that all return a status code and a XML
payload. For each one, I need need to test and verify
1. That they return the expected status code for the given input
(test called testWebserviceStatus in code, but now referred to as
TestA)
2. If the status code is correct, then I would like to verify 1 or
more properties of the payload. Every property is independent, so I
would like to have each property verification run as a separate test
(test called testWebserviceProperties in code, but now referred to as
TestB).

Other requrements
1. The ability to add/remove the list of webservices to test and
add/remove the list of properties to verify for each service without
updating the test code.
2. If Test A fails, then its associated TestB should be skipped
3. The test report should clearly show the success failure of each
TestA/TestB test along with the webservice/property that was being
tested

TestA takes its from an DataProvider fed by an XML file.
TestB requires the output (XML payload) of TestB, so I initially made
it depend on it via DependsOnGroups. However, since that meant that
any failure of TestA meant that no TestB would run, I resorted to
using a higher priority for TestA.


Question:
Given these requirements, is this the recommended TestNG way to
structure this test, or is there a better way.

I created a greatly simplified version of what I am trying to do at
https://github.com/Ulrich-Palha/TestNG-Question

Ulrich Palha

non lue,
5 janv. 2012, 15:25:0005/01/2012
à testng-users
Hi,

I am relatively new to TestNG, and I was hoping to get some feedback
from the more experienced users as to as to whether the approach I
used to write a data-driven test that depended on another data-driven
test (below) was OK or could be improved.

Thanks,


On Dec 28 2011, 12:12 pm, Ulrich Palha <upa...@gmail.com> wrote:
> I first posted this on StackOverflowhttp://stackoverflow.com/questions/8609516/best-way-to-write-testng-t...,
Répondre à tous
Répondre à l'auteur
Transférer
0 nouveau message