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

Use JUnit5 #691

Merged
merged 18 commits into from
Jan 16, 2019
Merged

Use JUnit5 #691

merged 18 commits into from
Jan 16, 2019

Conversation

ennru
Copy link
Member

@ennru ennru commented Dec 17, 2018

Benefits

  • JUnit 5 supports test class lifecycle control
    • useful for simpler admin client use in tests
    • useful for simpler embedded Kafka support
  • JUnit 5 makes use of Java 8 features (mainly lambdas)

This PR

  • adds sbt-jupiter-interface plugin to run JUnit 5-annotated tests
  • introduces KafkaTest and EmbeddedKafkaTest which rely on JUnit 5 per-class lifecyle
  • changes ProducerExampleTest and ConsumerExampleTest to use JUnit 5 instead
  • re-implements the JUnit base-classes for use of EmbeddedKafka in Java and makes use of constructor parameters instead of overrides (which look weird in Java)

@ennru ennru changed the title WIP: Use JUnit5 Use JUnit5 Jan 11, 2019
Copy link
Member

@2m 2m left a comment

Choose a reason for hiding this comment

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

Looking good. A couple of comments.

build.sbt Outdated Show resolved Hide resolved
build.sbt Outdated Show resolved Hide resolved
build.sbt Outdated
// -a Show stack traces and exception class name for AssertionErrors.
// -v Log "test run started" / "test started" / "test run finished" events on log level "info" instead of "debug".
// -q Suppress stdout for successful tests.
testOptions += Tests.Argument(TestFrameworks.JUnit, "-a", "-v", "-q"),
testOptions += Tests.Argument(jupiterTestFramework, "-a", "-v", "-q"),
Copy link
Member

Choose a reason for hiding this comment

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

It is interesting that with this change these options are still used when running JUnit 4 tests.

Copy link
Member Author

Choose a reason for hiding this comment

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

The JUnit 4 tests are now run by Jupiter.

Copy link
Member

Choose a reason for hiding this comment

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

That makes sense. Then we should be able to get rid of the "com.novocode" % "junit-interface" dependency.

Copy link
Member Author

Choose a reason for hiding this comment

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

As it turns out, the Junit 4 tests are not run by the Jupiter runner. When junit-interface is removed they don't run.

project/plugins.sbt Show resolved Hide resolved
Copy link
Member

@2m 2m left a comment

Choose a reason for hiding this comment

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

LGTM. I like the refactoring from method overrides to constructor parameters.

@ennru ennru added this to the 1.0-RC2 milestone Jan 15, 2019
@ennru
Copy link
Member Author

ennru commented Jan 15, 2019

I switched to use the Juniper Vintage Engine to run the JUnit 4 tests.
It has an issue with formatting sbt/sbt-jupiter-interface#33 and AssignmentTest.mustConsumeFromTheSpecifiedTopicPattern fails for me locally when using it?!

@ennru ennru merged commit 5d4bda4 into akka:master Jan 16, 2019
@ennru ennru deleted the ennru_junit5 branch January 16, 2019 14:00
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

Successfully merging this pull request may close these issues.

2 participants