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

Re: [junit] Can I create a dynamic JUnit ? (in Cactus Framework)

Expand Messages
  • Robert Watkins
    ... David Saff ... [snip] ... Cedric, I ve been telling you this for a year or so... Tests get instantiated at the start (one instance per test), they are run,
    Message 1 of 1 , Sep 1, 2005
      Cedric Beust wrote:
      >> From: junit@yahoogroups.com [mailto:junit@yahoogroups.com] On Behalf Of
      David Saff
      >
      >> That's a little misleading and a little untrue. _If_ you run
      >> JUnit on a class without a suite() method, or you have a
      >> suite() method that calls TestSuite.addTestSuite(Class), then
      >> _before any method is executed_, a fresh instance of the test
      >> class is created for each test method in the class. However,
      >> if you have a suite() method that calls
      >> TestSuite.addTest(Test), which Donny did, then no such "automatic"
      >> creation _should_ happen.
      >
      > Wow, you really had me there. I didn't believe it, so I tried it. And you
      > are right.
      [snip]
      > Now, what could possibly be the justification for this behavior?!?

      Cedric, I've been telling you this for a year or so... Tests get
      instantiated at the start (one instance per test), they are run, and
      then, depending on the runner, they are thrown away or reused. That's
      why setUp and tearDown are important; they move expensive work to a
      lifecycle around test execution.

      The justification is for the tools. Look at the behaviour in IntelliJ
      or Eclipse's test runners. You get a list of tests appearing, you can
      see which one is being executed, you can tell which ones have failed,
      and you can look at it afterwards to see why it failed. Yes, you can
      do it in other ways (as you've done in TestNG), but that's why it was
      done in JUnit 3. (4 also has this behaviour... the test
      invoking-object is created at the start and held around).

      You may want to re-read my JUnit Architecture Redux, Cedric...
      http://twasink.net/blog/archives/2004/04/junit_architect.html.

      Robert.
    Your message has been successfully submitted and would be delivered to recipients shortly.