Loading ...
Sorry, an error occurred while loading the content.

Re: [junit] Re: parameterized test with multiple test methods

Expand Messages
  • David Saff
    Barbara, Sorry for the long delay in responding. What you re seeing is indeed a bug. Do you have time to file it at https://github.com/KentBeck/junit/issues?
    Message 1 of 4 , May 9, 2012
    View Source
    • 0 Attachment
      Barbara,

      Sorry for the long delay in responding. What you're seeing is indeed a
      bug. Do you have time to file it at
      https://github.com/KentBeck/junit/issues? Thanks,

      David Saff

      On Mon, Apr 30, 2012 at 4:49 PM, barbara_a_bennett
      <barbara.bennett@...>wrote:

      > **
      >
      >
      > Maybe it is a case of me having bad expectations. I assumed that each of
      > the tests would get the parameters as they are defined in the parameter
      > section, not after they've been modified by a previous test method. I'm
      > used to the 3.8 "every test starts out fresh" idea. That isn't happening.
      > One of the parameters is "new StringBuilder()". I expected both methods to
      > get an empty StringBuilder. But, the second method is getting the
      > StringBuilder with the contents added in the first method.
      >
      > I tried resetting it in an @After method just to see what happens. The
      > code to set it to a new StringBuilder is executed but the second test
      > method still gets the StringBuilder with the contents added by the first
      > method.
      >
      > Is this the expected behavior?
      >
      >
      > --- In junit@yahoogroups.com, David Saff <saff@...> wrote:
      > >
      > > Hmm, that's odd. Not expected behavior.
      > >
      > > Were any of your parameters mutable types, such that if a value were
      > shared
      > > between multiple invocations, it could have been modified from one
      > > invocation, with effects seen in the next?
      > >
      > > Any chance you could share at least a skeleton of your test case? Thanks,
      > >
      > > David Saff
      > >
      > > On Fri, Apr 27, 2012 at 11:32 AM, barbara_a_bennett <barbara.bennett@...
      > > > wrote:
      > >
      > > > **
      >
      > > >
      > > >
      > > > Is the parameterized test class intended to have only one test method?
      > > >
      > > > I have created parameterized test classes with multiple test methods
      > that
      > > > use the same parameters with apparent success. However, when I tried it
      > > > with a new test class yesterday JUnit didn't behave in the expected
      > way.
      > > > This is in RAD 8.0.4 using JUnit 4.8.1.
      > > >
      > > > The assertEquals in the second test method is reported as a failure
      > even
      > > > though the method being tested returned the correct results (I traced
      > > > through with debug to verify). JUnit appended the result from the first
      > > > test method to the result from the second test method and reported the
      > > > second method as a failure because the combined result didn't match the
      > > > expected result.
      > > >
      > > > Am I using the parameterized test incorrectly by having multiple test
      > > > methods or is there a bug in JUnit?
      > > >
      > > >
      > > >
      > >
      > >
      > > [Non-text portions of this message have been removed]
      > >
      >
      >
      >


      [Non-text portions of this message have been removed]
    Your message has been successfully submitted and would be delivered to recipients shortly.