Skip to content
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

Revert to a simplified extension model #237

Merged

Conversation

sbrannen
Copy link
Member

@sbrannen sbrannen commented May 3, 2016

In order to postpone support for programmatic extension registration, the JUnit Team has decided to revert to a simplified extension model with a focus on extensions that are applied at extension points.

The commits in this pull request therefore address the following issues.

  • Removal of ExtensionPoint, ExtensionPointRegistry, and ExtensionRegistrar
  • Removal of the suffix ExtensionPoint in extension interface names
  • Introduction of before and after test method execution lifecycle callbacks
  • Simplification of the implementation of JUnit 5 test descriptors
  • Separation of concerns regarding user code and extension code
  • Eager lookup and validation of user-defined lifecycle callback methods during the discovery phase

Issue: #232


I hereby agree to the terms of the JUnit Contributor License Agreement.

sbrannen added 13 commits May 2, 2016 18:30
This commit separates the execution of extensions and user code with
regard to test lifecycle callbacks.

Issue: junit-team#232
This commit avoids unnecessary streaming and synthesizing of extensions
as lambda expressions for @BeforeAll and @afterall methods. Instead,
@BeforeAll and @afterall methods are now invoked directly using
standard for-loops.

Issue: junit-team#232
With this commit @beforeeach and @AfterEach methods are looked up and
validated eagerly during the discovery phase instead of late in the game
during the execution phase.

This commit also extracts a new LifecycleMethodUtils class from the
ClassTestDescriptor.

Issue: junit-team#232
@mmerdes
Copy link
Contributor

mmerdes commented May 5, 2016

I did a short analysis of potential conflicts between this PR and the changes in branch issue58-dynamic-tests-with-new-resolvers. There are only 2 files changed by both branches. The difference in MethodInvoker is trivial, the conflicts in MethodTestDescriptor are more substantial but should probably be resolvable...

@mmerdes
Copy link
Contributor

mmerdes commented May 5, 2016

BTW
I like the unformatted 'indentation art' in MethodTestDescriptor.execute() :)
While not 'spotless' it sure helps expressing a meaning which would not be achievable with merely syntactic means.

@sbrannen
Copy link
Member Author

sbrannen commented May 5, 2016

Thanks for checking for potential conflicts.

I hope the merging with MethodTestDescriptor isn't too time consuming for you!

@sbrannen
Copy link
Member Author

sbrannen commented May 5, 2016

I like the unformatted 'indentation art' in MethodTestDescriptor.execute() :)

"Indentation art" --> you've coined a new term!

We've already been using that technique in our tests when we want to verify extension execution order, so it only seemed fitting to do the same in the production code for exactly the same reason: visualization of the wrapping nature of extensions and lifecycle callbacks. So I'm glad you like it. 😉

*
* @since 5.0
*/
final class LifecycleMethodUtils {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice. I like the idea of having a central place of how to lookup and find the different pieces. We also do have some more of these things in extra classes. I am wondering if we could consolidate those all into a "function" library. This will not be part of this PR, just an idea I wanted to mention.

@bechte
Copy link
Contributor

bechte commented May 6, 2016

Great job! Thanks. I support the changes in this PR and vote for merging it into master. Let's talk about it in our call.

@@ -78,6 +76,8 @@ public ClassTestDescriptor(UniqueId uniqueId, Class<?> testClass) {

this.beforeAllMethods = findBeforeAllMethods(testClass);
this.afterAllMethods = findAfterAllMethods(testClass);
this.beforeEachMethods = findBeforeEachMethods(testClass);
this.afterEachMethods = findAfterEachMethods(testClass);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Where are the exceptions thrown by these methods caught?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To be addressed in #242. 😉

@marcphilipp
Copy link
Member

I think we need a follow-up issue to take care of exception handling in the JUnit 5 TestEngine. E.g. invalid before-each methods should not lead to a complete abortion of the discovery process.

@marcphilipp
Copy link
Member

marcphilipp commented May 6, 2016

Team Decisions:

@sbrannen sbrannen force-pushed the issue232-simplified-extension-model branch from 76193be to 744eb9b Compare May 6, 2016 10:39
@sbrannen sbrannen merged commit 744eb9b into junit-team:master May 6, 2016
sbrannen added a commit that referenced this pull request May 6, 2016
…odel

* issue232-simplified-extension-model:
  Update User Guide regarding renamed and new extensions
  Delete discussion of programmatic extension registration in User Guide
  Polish JUnit 5 test descriptors
  Eagerly load and validate @beforeeach & @AfterEach methods
  Do not synthesize @BeforeAll & @afterall methods as extensions
  Do not mix execution of extensions and user code
  Polish JUnit 5 test descriptors
  Polish Javadoc for extension APIs
  Remove ExtensionPointRegistry and ExtensionRegistrar
  Remove ExtensionPoint API in favor of Extension
  Simplify extension streaming and invocation algorithms
  Introduce before & after test method callback APIs
  Rename test lifecycle callback extension APIs
  Rename ExceptionHandlerExtensionPoint to ExceptionHandler
@sbrannen sbrannen self-assigned this May 6, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants