junit5

JUnit 5 — global timeout?

萝らか妹 提交于 2020-05-29 03:28:23
问题 In JUnit 5, what is the best way to enforce a global timeout for all tests? I see that JUnit 4 has a @Rule feature, but this has been removed in JUnit 5. And I would prefer not to have to copy-paste assertTimeoutPreemptively for every test. 回答1: You mentioned the JUnit 4 Timeout @Rule, which allows specifying timeouts on a per-test class basis. JUnit 5.5 has a direct equivalent as an experimental feature in the @Timeout annotation. This can be applied to the class level in the same manner as

How can I test a micronaut Service with junit5?

三世轮回 提交于 2020-05-24 05:14:30
问题 I tried to run the mathService example presented under: https://micronaut-projects.github.io/micronaut-test/latest/guide/#junit5 which should explain testing a micronaut service with junit5. I added testAnnotationProcessor "io.micronaut:micronaut-inject-java" testCompile "io.micronaut.test:micronaut-test-junit5:1.1.3" testCompile "org.mockito:mockito-junit-jupiter:2.22.0" testRuntime "org.junit.jupiter:junit-jupiter-engine:5.1.0" to my dependencies. I coded MathService, MathServiceImpl in src

Mocked suspend lambda returns null in Mockito

南楼画角 提交于 2020-05-14 04:12:44
问题 Dependencies : testImplementation "androidx.arch.core:core-testing:2.0.0" testImplementation 'org.mockito:mockito-core:3.3.0' testImplementation 'org.mockito:mockito-inline:2.8.47' testImplementation "com.nhaarman.mockitokotlin2:mockito-kotlin:2.2.0" ViewModel : fun <T : Any> doSomething( result: Result<T>, callback: Callback<T>? = null ) { when (result.status) { Result.Status.SUCCESS -> { callback?.success(result.data) } Result.Status.ERROR -> { callback?.error(result) } } } suspend fun <T :

Mocked suspend lambda returns null in Mockito

为君一笑 提交于 2020-05-14 04:06:45
问题 Dependencies : testImplementation "androidx.arch.core:core-testing:2.0.0" testImplementation 'org.mockito:mockito-core:3.3.0' testImplementation 'org.mockito:mockito-inline:2.8.47' testImplementation "com.nhaarman.mockitokotlin2:mockito-kotlin:2.2.0" ViewModel : fun <T : Any> doSomething( result: Result<T>, callback: Callback<T>? = null ) { when (result.status) { Result.Status.SUCCESS -> { callback?.success(result.data) } Result.Status.ERROR -> { callback?.error(result) } } } suspend fun <T :

Mocked suspend lambda returns null in Mockito

 ̄綄美尐妖づ 提交于 2020-05-14 04:04:22
问题 Dependencies : testImplementation "androidx.arch.core:core-testing:2.0.0" testImplementation 'org.mockito:mockito-core:3.3.0' testImplementation 'org.mockito:mockito-inline:2.8.47' testImplementation "com.nhaarman.mockitokotlin2:mockito-kotlin:2.2.0" ViewModel : fun <T : Any> doSomething( result: Result<T>, callback: Callback<T>? = null ) { when (result.status) { Result.Status.SUCCESS -> { callback?.success(result.data) } Result.Status.ERROR -> { callback?.error(result) } } } suspend fun <T :

Java JUnit 5 annotations differences

心不动则不痛 提交于 2020-05-12 13:59:51
问题 I see there was introduced the new JUnit Jupiter according to JUnit 5 User Guide. JUnit 5 = JUnit Platform + JUnit Jupiter + JUnit Vintage I am confused about the same-named annotations I use across the library. Is there any significant difference between these two ones? org.junit.Test org.junit.jupiter.api.Test The description from the linked page above explains the annotation org.junit.jupiter.api.Test as following: Denotes that a method is a test method. Unlike JUnit 4’s @Test annotation,

Java JUnit 5 annotations differences

◇◆丶佛笑我妖孽 提交于 2020-05-12 13:59:48
问题 I see there was introduced the new JUnit Jupiter according to JUnit 5 User Guide. JUnit 5 = JUnit Platform + JUnit Jupiter + JUnit Vintage I am confused about the same-named annotations I use across the library. Is there any significant difference between these two ones? org.junit.Test org.junit.jupiter.api.Test The description from the linked page above explains the annotation org.junit.jupiter.api.Test as following: Denotes that a method is a test method. Unlike JUnit 4’s @Test annotation,

Unit Testing Freemarker templates in SpringBoot - unable to initialize freemarker configuration

我与影子孤独终老i 提交于 2020-04-10 14:57:26
问题 we are using Freemarker for generating the HTML code for the emails our application is going to be sending. Our usage and configuration is based off of https://github.com/hdineth/SpringBoot-freemaker-email-send Particularly: package com.example.techmagister.sendingemail.config; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; import org.springframework.core.io.ResourceLoader; import org.springframework.ui.freemarker

Unit Testing Freemarker templates in SpringBoot - unable to initialize freemarker configuration

馋奶兔 提交于 2020-04-10 14:57:08
问题 we are using Freemarker for generating the HTML code for the emails our application is going to be sending. Our usage and configuration is based off of https://github.com/hdineth/SpringBoot-freemaker-email-send Particularly: package com.example.techmagister.sendingemail.config; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; import org.springframework.core.io.ResourceLoader; import org.springframework.ui.freemarker

JDK 11 + JUnit 5 + Jigsaw: Junit fails to run tests for `module-info`

☆樱花仙子☆ 提交于 2020-03-22 06:41:06
问题 I try to use JUnit 5 in a Gradle project. compileJava and compileTestJava both succeed, but test fails with the strange message Could not execute test class 'module-info'. (message from stacktrace): > Task :test FAILED FAILURE: Build failed with an exception. * What went wrong: Execution failed for task ':test'. > There were failing tests. See the report at: file:///Users/axel/git/utility/build/reports/tests/test/index.html The test result file hints me that " failed to execute tests ", but