junit5

Produce tree output with Surefire like the JUnit 5 console launcher

房东的猫 提交于 2019-12-12 11:55:58
问题 The Console Launcher that comes with JUnit Platform (from JUnit 5) produces a quite nice summary view at the end. The Maven Surefire plugin, however, has a very simple output. Is it possible to create with Surefire output similar to what the launches creates? 回答1: My current workaround is to disable surefire and use exec-maven-plugin to manually run ConsoleLauncher : <!-- disable surefire --> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-surefire-plugin</artifactId>

Why do JUnit 5 tests not inherit @Test annotation from abstract classes?

时光毁灭记忆、已成空白 提交于 2019-12-12 08:49:43
问题 I just realized (while migrating legacy code from JUnit 4 to JUnit 5) that some of our test methods are not executed because they don't have the @Test annotation. They don't have it, because they override methods from an abstract superclass (where the annotation is present). I can easily fix this by adding the @Test to each method. But I was wondering if this is intended behavior. It changed from JUnit 4 to 5 but I can't find anything about it in the official JUnit5 User Guide or anywhere

JUnit5 - How to get test result in AfterTestExecutionCallback

泪湿孤枕 提交于 2019-12-12 08:48:57
问题 I write JUnit5 Extension. But I cannot find way how to obtain test result. Extension looks like this: import org.junit.jupiter.api.extension.AfterTestExecutionCallback; import org.junit.jupiter.api.extension.TestExtensionContext; public class TestResultExtension implements AfterTestExecutionCallback { @Override public void afterTestExecution(TestExtensionContext context) throws Exception { //How to get test result? SUCCESS/FAILED } } Any hints how to obtain test result? 回答1: As other answers

JUnit 5 under Gradle with multiple source sets

回眸只為那壹抹淺笑 提交于 2019-12-12 08:48:18
问题 I've got a project I'm putting together that I want to use JUnit 5 for. I've got this working fine for Unit Tests already. I do however have multiple test source sets - I've got an additional one for Acceptance Tests. I'm struggling to work out how to get JUnit 5 to run the Unit Tests - defined in src/test - in one task and the Acceptance Tests - defined in the "acceptanceTest" sourceSet and located in "src/acceptance" - in another task. I have previously got this working with JUnit 4 and

JUnit 5 - Providing setUp and tearDown for an entire Test Suite

a 夏天 提交于 2019-12-11 18:17:25
问题 My requirement is to have some initialization done for a set of tests and clear it off once all the tests are complete. These tests spin over a few test classes as they are not closely related, but require a common initialization. I am using @SelectClasses to form the suite and trying to make use of @ExtendWith using a custom extension that should handle the pre and post processing. This does not work and I am unsure if an appropriate solution exists in JUnit. Sharing the sample code of what

Interaction between Spring Boot and JUnit 5 — must use the overall artifacts not the individuals?

别等时光非礼了梦想. 提交于 2019-12-11 17:41:53
问题 This question has been asked before (e.g. here), but my observation was not the same as those previously reported. I noticed that to get JUnit 5 to work, I must include the overall JUnit 5 artifact testImplementation('org.junit.jupiter:junit-jupiter:5.5.1') If I, instead, included the individual artifacts, then the JUnit test would not be picked up testImplementation('org.junit.platform:junit-platform-runner:1.3.1') testImplementation('org.junit.platform:junit-platform-launcher:1.0.0')

Discovering test with JUnit 5 doesn't execute LoggingListener (implementation of TestExecutionListeners)

a 夏天 提交于 2019-12-11 15:15:11
问题 I'm using JUnit Jupiter version 5.0.0 (Release version) and I'm trying to use the test discovery feature. The documentation of Junit can be found in 7.1.1. Discovering Tests from http://junit.org/junit5/docs/5.0.0/user-guide/#launcher-api-discovery My implementation is: import static org.junit.platform.engine.discovery.ClassNameFilter.includeClassNamePatterns; import static org.junit.platform.engine.discovery.DiscoverySelectors.selectPackage; import org.junit.platform.launcher.Launcher;

Getting the values of parameters for ParameterizedTests in TestExecutionListener

无人久伴 提交于 2019-12-11 14:23:14
问题 In my test framework, I have to manually generate the TestSuite.xml. In Junit4, the "Description" object passed by the listener contains the value of the parameters passed in a parameterized test, so the XML looks like this. <testcase 11 classname="com.workday.scramble.datagen.generator.regex.generator.RegexGenTest" 12 name="testTransformAndGenerate[77: RegexGenTest: [0-9]{1,28}]" 13 time="9.1E-4"/> 14 <testcase 15 classname="com.workday.scramble.datagen.generator.regex.generator.RegexGenTest

How to write a jqwik generator method with nested generators

做~自己de王妃 提交于 2019-12-11 09:49:55
问题 Using jqwik.net, trying to generate a Rule class with a a nested RuleConfig class inside it. The RuleConfig class has a nested ruleProps which is a Map The statusReturnedFromApplyingRule method always returns an initialized Rule instead of using the @provide method values ?? Returned Rule: rule:Rule{ruleId='null', inputMetricSelector=null, ruleConfig='RuleConfig{ruleType='null', ruleProps={}}'}, elements:[{}] Here is my code: public class RangeMatchRuleTest { @Property @Report(Reporting

Maven silently fails to find JUnit tests to run

天大地大妈咪最大 提交于 2019-12-11 07:47:32
问题 I've got a new Java project open in IntelliJ with Maven as its build tool, with one class and one JUnit 5 test class at the moment. When I direct IntelliJ to run tests, individually or all together, it works. But when I go to the terminal and hit mvn clean test or do the same from the Maven pane within IntelliJ, it skips over the tests. Unlike the questioner with this similar question, however, I'm not getting any error message. The test class is found and does compile. I do not have the same