What I want: even when a failure occurs in the method marked with
@AfterMethod(alwaysRun = true), he will continue running the tests
that follow.
However, I understand from a forum post in 2007 that this will not
happen by design.
But can't I still run them by setting alwaysRun = true on the test ? I
tried that but it will not work...
I tried something like @Test(alwaysRun = true).
What happens now when an exception occurs in the @AfterMethod method,
it will run all the @AfterMethod methods of the test that follow, but
not their @BeforeMethod of all the tests that follow :(...
I don't really understand that. Why the the after methods but not the
before methods ?
Why does it even bother running any of the test (their after methods)
that follow considering the above design decision?
What is the expected behavior when an exception occurs in the after
method for the tests that follow?
Ed
--
You received this message because you are subscribed to the Google Groups "testng-users" group.
To post to this group, send email to testng...@googlegroups.com.
To unsubscribe from this group, send email to testng-users...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/testng-users?hl=en.
Ed
On Mar 22, 5:49 pm, Cédric Beust ♔ <cbe...@google.com> wrote:
> I think your main problem is that you are writing a test in your
> @AfterMethod. That's going against the design of TestNG: configuration
> methods are meant to configure or tear down your tests, not perform actual
> tests.
>
> You should move this test logic in a real test method and have it depend on
> all the other test methods that need to run first.
>
> --
> *Cédric*
> >> *Cédric*
> >>> testng-users...@googlegroups.com<testng-users%2Bunsu...@googlegroups.com>
> >>> .
> >>> For more options, visit this group at
> >>>http://groups.google.com/group/testng-users?hl=en.
>
> >> --
> >> You received this message because you are subscribed to the Google Groups
> >> "testng-users" group.
> >> To post to this group, send email to testng...@googlegroups.com.
> >> To unsubscribe from this group, send email to
> >> testng-users...@googlegroups.com<testng-users%2Bunsu...@googlegroups.com>
> >> .
> >> For more options, visit this group at
> >>http://groups.google.com/group/testng-users?hl=en.
>
> > --
> > You received this message because you are subscribed to the Google Groups
> > "testng-users" group.
> > To post to this group, send email to testng...@googlegroups.com.
> > To unsubscribe from this group, send email to
> > testng-users...@googlegroups.com<testng-users%2Bunsu...@googlegroups.com>
Thanks for the idea, but the "depends" attribute (either a method orI want a run a certain method -after- each test method (in a group) .
group) is used to run method(s) -before- a test method.
So I don't want to run it after "all" my hundreds of test are finished
(which I could do with a dependsOnGroup), but I need to run this -
after- method after "each" test method.
How can I do this using the testng annotations?
To unsubscribe from this group, send email to testng-users...@googlegroups.com.
On Mon, Mar 22, 2010 at 4:17 PM, Ed <post2...@gmail.com> wrote:
Thanks for the idea, but the "depends" attribute (either a method orI want a run a certain method -after- each test method (in a group) .
group) is used to run method(s) -before- a test method.
So I don't want to run it after "all" my hundreds of test are finished
(which I could do with a dependsOnGroup), but I need to run this -
after- method after "each" test method.
How can I do this using the testng annotations?Try BeforeGroups and AfterGroups
On Mar 23, 6:55 am, Cédric Beust ♔ <cbe...@google.com> wrote:
> On Mon, Mar 22, 2010 at 6:08 PM, Kartik Kumar <krishnan.1...@gmail.com>wrote:
>
>
>
> > On Mon, Mar 22, 2010 at 4:17 PM, Ed <post2edb...@gmail.com> wrote:
>
> >> Thanks for the idea, but the "depends" attribute (either a method or
> >> group) is used to run method(s) -before- a test method.
> >> I want a run a certain method -after- each test method (in a group) .
> >> So I don't want to run it after "all" my hundreds of test are finished
> >> (which I could do with a dependsOnGroup), but I need to run this -
> >> after- method after "each" test method.
> >> How can I do this using the testng annotations?
>
> > Try BeforeGroups and AfterGroups
>
> Same problem: you shouldn't be writing tests in configuration methods.
>
> I think I have a solution, I'll write it up and I'll post it here.
>
> --
> *Cédric*
Thanks guys.
Ok Cedric, I am looking forward to it.
One more thing: Like mentioned above, when an exception occurs in the
after method, all following tests are run with exceptions (all
following after methods are run and not all before methods)...
Like I understand from you, testNG doesn't recover from an exception
in an after method. So I think that testNG should stop testing more
gracefully instead of the running all tests half, something I observe
now. This is a bit strange especially if you have a few hundreds tests
which are run half.
Or not ?
The alternative would be that I check if an exception occurs in the
after method and dont' do anything, because otherwise a after method
of the following test is called of which the pre-conditions aren't met
because the before method isn't called... If testNG simple stops in
case an exception occurs in an configuration method, these problems
will not occur.
On Mar 23, 7:21 pm, Cédric Beust ♔ <cbe...@google.com> wrote:
> Hi Ed,
>
Can you please let me know if I should report the remark about
"graceful stopping testing" as a bug/enchancement? (listed below)