junit5

How to get JUnit tests annotated with @Tag to be executed in suite that has @IncludeTags?

笑着哭i 提交于 2021-02-10 14:36:24
问题 I have the following code: Test class: @Tag("foo") class SomeIT { @Test public void testSomeStuff() { ... } } Suite class: @RunWith(JUnitPlatform.class) @IncludeTags({"foo"}) //@SelectPackages("org.foo") public class SomeITSuite { } My pom.xml : <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"> <modelVersion>4.0.0</modelVersion> <groupId>org

@IfProfileValue not working with JUnit 5 SpringExtension

大城市里の小女人 提交于 2021-02-08 13:19:38
问题 I use junit5 with spring-starter-test, in order to run spring test I need to use @ExtendWith instead of @RunWith . However @IfProfileValue work with @RunWith(SpringRunner.class) but not with @ExtendWith(SpringExtension.class) , below is my code: @SpringBootTest @ExtendWith({SpringExtension.class}) class MyApplicationTests{ @Test @DisplayName("Application Context should be loaded") @IfProfileValue(name = "test-groups" , value="unit-test") void contextLoads() { } } so the contextLoads should be

@IfProfileValue not working with JUnit 5 SpringExtension

Deadly 提交于 2021-02-08 13:19:31
问题 I use junit5 with spring-starter-test, in order to run spring test I need to use @ExtendWith instead of @RunWith . However @IfProfileValue work with @RunWith(SpringRunner.class) but not with @ExtendWith(SpringExtension.class) , below is my code: @SpringBootTest @ExtendWith({SpringExtension.class}) class MyApplicationTests{ @Test @DisplayName("Application Context should be loaded") @IfProfileValue(name = "test-groups" , value="unit-test") void contextLoads() { } } so the contextLoads should be

How to run a Junit5 test with Android dependencies and robolectric

笑着哭i 提交于 2021-02-07 13:15:45
问题 I am trying to run a unit test like that: @org.junit.jupiter.api.Test void junit5codeCoverage() { final int result = new Foo().junit5(); Assert.assertEquals(Looper.getMainLooper().getThread(), Thread.currentThread()); assertEquals(-1, result); } That is a Junit5 test with Android dependencies (i.e Looper.getMainLooper() ) with Robolectric. I am using the junit5 android plugin from mannodermaus that allows running junit5 within Android setups. But this does not work out of the box because it

Error “TestEngine with ID 'junit-vintage' failed to discover tests” with Spring Boot 2.2

自闭症网瘾萝莉.ら 提交于 2021-02-07 11:15:24
问题 I have a simple app using Spring Boot and Junit 5: When using Spring Boot 2.1 (e.g, 2.1.8 or 2.1.12), my unit tests run smoothly When using Spring Boot 2.2 (e.g., 2.2.2.RELEASE or 2.3.2.RELEASE) my unit tests fail with error message [ERROR] Failed to execute goal org.apache.maven.plugins:maven-surefire-plugin:2.22.2:test (default-test) on project XXX: There are test failures. [ERROR] [ERROR] Please refer to D:\Projets\workspace\XXX\target\surefire-reports for the individual test results.

Error “TestEngine with ID 'junit-vintage' failed to discover tests” with Spring Boot 2.2

*爱你&永不变心* 提交于 2021-02-07 11:14:38
问题 I have a simple app using Spring Boot and Junit 5: When using Spring Boot 2.1 (e.g, 2.1.8 or 2.1.12), my unit tests run smoothly When using Spring Boot 2.2 (e.g., 2.2.2.RELEASE or 2.3.2.RELEASE) my unit tests fail with error message [ERROR] Failed to execute goal org.apache.maven.plugins:maven-surefire-plugin:2.22.2:test (default-test) on project XXX: There are test failures. [ERROR] [ERROR] Please refer to D:\Projets\workspace\XXX\target\surefire-reports for the individual test results.

How to manage failed tests in JUnit5

孤街醉人 提交于 2021-02-07 09:54:38
问题 I'm migrating to JUnit5 and I'd like to know if there is an easy way in JUnit5 to know when a test failed or not, just like we had in JUnit4 with TestWatcher. I did some research and found similar, but open questions, like this one: https://github.com/junit-team/junit5/issues/542 Since most of them are quite old, I'm asking just in case there is a recent solution. The idea is to be able to do a screenshot or add some message into my log. So, is there a listener or extension or something that

Spring Boot Camel Testing

不想你离开。 提交于 2021-02-07 09:21:02
问题 I need to test Camel routes in a Spring Boot Application. I've the Spring boot main class with all the necessary beans declared in it. I am using the CamelSpringJUnit4ClassRunner.class. Added my Spring boot main class in @ContextConfiguration as it contains all the configurations. I don't have a separate configuration class. I 've autowired CamelContext in my Test class: @Autowired CamelContext camelContext; But the test fails with the error: Caused by: org.springframework.beans.factory

Spring Boot Camel Testing

≯℡__Kan透↙ 提交于 2021-02-07 09:20:27
问题 I need to test Camel routes in a Spring Boot Application. I've the Spring boot main class with all the necessary beans declared in it. I am using the CamelSpringJUnit4ClassRunner.class. Added my Spring boot main class in @ContextConfiguration as it contains all the configurations. I don't have a separate configuration class. I 've autowired CamelContext in my Test class: @Autowired CamelContext camelContext; But the test fails with the error: Caused by: org.springframework.beans.factory

spring boot test junit null pointer exception

半世苍凉 提交于 2021-02-05 06:10:48
问题 im new on this of unit tests, so im trying to code the unit test for my service, right now i have this class package com.praxis.topics.service; import com.praxis.topics.exception.EntityNotFoundException; import com.praxis.topics.model.Topic; import com.praxis.topics.model.enums.Status; import com.praxis.topics.repository.TopicRepository; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import java.time.LocalDateTime; import java