The Artima Developer Community
Sponsored Link

SuiteRunner Forum
Bug report? testSucceeded method called even when a test fails...

2 replies on 1 page. Most recent reply: Mar 19, 2003 5:40 PM by Bill Venners

Welcome Guest
  Sign In

Go back to the topic listing  Back to Topic List Click to reply to this topic  Reply to this Topic Click to search messages in this forum  Search Forum Click for a threaded view of the topic  Threaded View   
Previous Topic   Next Topic
Flat View: This topic has 2 replies on 1 page
Andrew Matthews

Posts: 9
Nickname: taxman
Registered: Feb, 2003

Bug report? testSucceeded method called even when a test fails... Posted: Mar 19, 2003 8:12 AM
Reply to this message Reply
Advertisement
Hello. I created a class that implements the Reporter interface and gathers and reports statistical data regarding the number of tests, the number of passing tests, etc. I have made the discovery that, while Reporter.testFailed is called when a test fails or throws an exception (as it should be), the Reporter.testSucceeded method is also called REGARDLESS of whether the test actually passed. My test fails by throwing an SQLException, which inherits from java.lang.Exception, if that matters.

I don't know if this is a bug or a design decision (I suspect it is a bug), but it would probably be a good idea to avoid calling Reporter.testSucceeded after a test failure. At any rate, I just thought I should give everybody a heads-up on this.


Bill Venners

Posts: 2284
Nickname: bv
Registered: Jan, 2002

Re: Bug report? testSucceeded method called even when a test fails... Posted: Mar 19, 2003 10:42 AM
Reply to this message Reply
> Hello. I created a class that implements the Reporter
> interface and gathers and reports statistical data
> regarding the number of tests, the number of passing
> tests, etc. I have made the discovery that, while
> Reporter.testFailed is called when a test fails or throws
> an exception (as it should be), the Reporter.testSucceeded
> method is also called REGARDLESS of whether the test
> actually passed. My test fails by throwing an
> SQLException, which inherits from java.lang.Exception, if
> that matters.
>
> I don't know if this is a bug or a design decision (I
> suspect it is a bug), but it would probably be a good idea
> to avoid calling Reporter.testSucceeded after a test
> failure. At any rate, I just thought I should give
> everybody a heads-up on this.

Ack. That's a bug. I just looked at the code. It has been in there since we put setUpFixture and tearDownFixture back in, long before the initial public release. What shocks me is that we never noticed it. Of course, I never imagined the problem so I didn't write a test that would detect it. But the evidence was staring me in the face in the output of every single test that ran with a failure, and I still never noticed it.

Thanks for reporting this issue. I'll fix this in the next release. Your interpretation of what makes sense is what I had intended. A test completes with either a testSucceeded or a testFailed report, but never both.

Bill Venners

Posts: 2284
Nickname: bv
Registered: Jan, 2002

Re: Bug report? testSucceeded method called even when a test fails... Posted: Mar 19, 2003 5:40 PM
Reply to this message Reply
> What shocks me is that we never
> noticed it. Of course, I never imagined the problem so I
> didn't write a test that would detect it. But the evidence
> was staring me in the face in the output of every single
> test that ran with a failure, and I still never noticed
> it.
>
I later realized that this bug first appeared two releases ago when I changed the behavior of Suite's executeTestMethod, based on comments in a previous post from Andrew. So it wasn't in there forever, but there obviously wasn't a test to detect it.

Flat View: This topic has 2 replies on 1 page
Topic: org.suitrunner package Previous Topic   Next Topic Topic: Running JUnit Tests with Artima SuiteRunner

Sponsored Links



Google
  Web Artima.com   

Copyright © 1996-2019 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use