Test execution chain with interceptors

View: New views
3 Messages — Rating Filter:   Alert me  

Test execution chain with interceptors

by Alistair Israel :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hi, Kent/David.

Just did some testing and it seems that the execution chain with
interceptors is actually:

   - @Before
   - ExternalResource#before()
   - @Test
   - ExternalResource#after()
   - @After

Which basically means that any @Before code can't use the interceptors. I
think it would've been nice to, say, use a @Before method to fill a
TemporaryFolder with files for all subsequent tests. For example:

  @Rule
  public TemporaryFolder folder = new TemporaryFolder();

  @Before
  public void createFiles() {
    folder.newFile("test.txt");
  }

Is this how you guys really wanted it? If so, any suggestions for my use
case, other than creating a whole new interceptor of my own?

- alistair
--
http://alistairisrael.wordpress.com


[Non-text portions of this message have been removed]


RE: Test execution chain with interceptors

by kentb :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Thanks for the note. We've had a couple of comments that people expected
rules to run before @Before. We placed them where we did not for any
particular reason, so we'll experiment with moving them earlier in the block
and see what breaks.
 
Regards,
 
Kent

  _____  

From: junit@... [mailto:junit@...] On Behalf Of
Alistair Israel
Sent: Tuesday, September 08, 2009 7:45 PM
To: junit@...
Subject: [junit] Test execution chain with interceptors


 

Hi, Kent/David.

Just did some testing and it seems that the execution chain with
interceptors is actually:

- @Before
- ExternalResource#before()
- @Test
- ExternalResource#after()
- @After

Which basically means that any @Before code can't use the interceptors. I
think it would've been nice to, say, use a @Before method to fill a
TemporaryFolder with files for all subsequent tests. For example:

@Rule
public TemporaryFolder folder = new TemporaryFolder();

@Before
public void createFiles() {
folder.newFile("test.txt");
}

Is this how you guys really wanted it? If so, any suggestions for my use
case, other than creating a whole new interceptor of my own?

- alistair
--
http://alistairisra <http://alistairisrael.wordpress.com> el.wordpress.com

[Non-text portions of this message have been removed]






[Non-text portions of this message have been removed]


Re: Test execution chain with interceptors

by Alistair Israel :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hi, Kent.

Pulled from GitHub and built Junit locally (calling it "junit-4.8-SNAPSHOT",
following Maven conventions).

I can confirm that the test execution chain now goes:

   - ExternalResource#before()
   - @Before
   - @Test
   - @After
   - ExternalResource#after()

I've also confirmed that, during the @Before method the TemporaryFolder rule
is fully 'initialized' and ready to use, letting us write scaffolding code
in @Before to populate the TemporaryFolder with files.

Will periodically pull from junit master and keep using my 4.8-SNAPSHOT in
my unit tests from now on to 'beta test' the next release. Thanks!

- alistair
--
http://alistairisrael.wordpress.com


[Non-text portions of this message have been removed]