Skip to content

Overriding methodBlock (customising test object for each FrameworkMethod call) #1036

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
petergeneric opened this issue Dec 1, 2014 · 2 comments

Comments

@petergeneric
Copy link
Contributor

I have a BlockJUnit4ClassRunner implementation for Guice, I'm using Guice to construct fresh instances of the test class in createTest, however I'd like to customise the environment passed in for each test method (at the minute I can only customise it per test class). In order to have enough information to do this I would need to have a variant of createTest() that takes a FrameworkMethod (or to override methodBlock(FrameworkMethod) myself).

I can't do either of these, because when overriding methodBlock(FrameworkMethod) one of the methods I need to call, withRules(FrameworkMethod,Object,Statement), is private.

If what I'm doing isn't recommended can you recommend an alternative approach?

@kcooney
Copy link
Member

kcooney commented Dec 1, 2014

Adding an override of createTest() that takes a FrameworkMethod (and calls the existing createTest() method) sounds reasonable. Can you send us a pull?

petergeneric added a commit to petergeneric/junit that referenced this issue Dec 1, 2014
…FrameworkMethod) to allow implementations to provide a custom instance of the test for each FrameworkMethod invocation
petergeneric added a commit to petergeneric/junit that referenced this issue Dec 1, 2014
…FrameworkMethod) to allow implementations to provide a custom instance of the test for each FrameworkMethod invocation
@petergeneric
Copy link
Contributor Author

I've submitted pull request #1037 for this

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants
@kcooney @petergeneric and others