junit5

Mockito gives UnfinishedVerificationException when it seems OK

情到浓时终转凉″ 提交于 2019-12-18 01:25:44
问题 Mockito appears to be throwing an UnfinishedVerificationException when I think I've done everything correctly. Here's my partial test case: HttpServletRequest req = mock(HttpServletRequest.class); when(req.getHeader("Authorization")).thenReturn("foo"); HttpServletResponse res = mock(HttpServletResponse.class); classUnderTest.doMethod(req, res); // Use the mock verify(res, never()); verify(req).setAttribute(anyString(), anyObject()); And here's the partial class and method: class

Mockito gives UnfinishedVerificationException when it seems OK

南楼画角 提交于 2019-12-18 01:25:07
问题 Mockito appears to be throwing an UnfinishedVerificationException when I think I've done everything correctly. Here's my partial test case: HttpServletRequest req = mock(HttpServletRequest.class); when(req.getHeader("Authorization")).thenReturn("foo"); HttpServletResponse res = mock(HttpServletResponse.class); classUnderTest.doMethod(req, res); // Use the mock verify(res, never()); verify(req).setAttribute(anyString(), anyObject()); And here's the partial class and method: class

How to specify which @Tag should be used for JUnit in IntelliJ IDEA

拟墨画扇 提交于 2019-12-17 20:45:09
问题 Is there a way to specify from the build in JUnit5 Runner of IntelliJ that only test methods with specific @Tag should be tested (or the opposite, that all tests except those with a specific @Tag, should be executed)? I know how to do it with maven, but is it possible with just the IntelliJ UI? Best regards, Dieter 回答1: With https://youtrack.jetbrains.com/issue/IDEA-163481 fixed, it is now possible since IJ 2018.1 -- for details see @Nicolau 's answer. 回答2: Now it is possible with Intellij

Gradle 5 JUnit BOM and Spring Boot Incorrect Versions

梦想与她 提交于 2019-12-17 09:53:50
问题 I am using Gradle 5's BOM (Bill of Materials) feature. This is how I describe it for my JUnit 5 dependencies: testImplementation(enforcedPlatform("org.junit:junit-bom:5.4.0")) // JUnit 5 BOM testImplementation("org.junit.jupiter:junit-jupiter-api") testRuntimeOnly("org.junit.jupiter:junit-jupiter-engine") testImplementation("org.junit.jupiter:junit-jupiter-params") My assumption is that providing the BOM will resolve the versions of the dependencies to 5.4.0 . However, they get resolved to 5

@Disabled is not working in JUnit5

你说的曾经没有我的故事 提交于 2019-12-14 00:52:45
问题 I want to use Junit 5 in Maven project: <dependency> <groupId>org.junit.jupiter</groupId> <artifactId>junit-jupiter-engine</artifactId> <version>5.2.0</version> <scope>test</scope> </dependency> I want currently to disable the test: import java.util.Arrays; import java.util.HashMap; import java.util.LinkedHashMap; import java.util.Map; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Disabled; import static java.util.stream.Collectors

Exception occured in Test when add Hibernate ORM Panache in Quarkus

拟墨画扇 提交于 2019-12-13 20:35:58
问题 Before I added hibernate orm Panache, the tests for jaxrs is working. but when I added it, it does not work, and throw the following exceptions. The complete codes is hosted on Github. org.junit.jupiter.api.extension.TestInstantiationException: TestInstanceFactory [io.quarkus.test.junit.QuarkusTestExtension] failed to instantiate test class [com.example.PostResourceTest]: io.quarkus.builder.BuildException: Build failure: Build failed due to errors [error]: Build step io.quarkus.hibernate.orm

Powermock throws ClassNotPreparedException when using JUnit 5

て烟熏妆下的殇ゞ 提交于 2019-12-13 04:22:55
问题 I have a sample test class where I want to mock a static class.My build.gradle is like testCompile group: 'org.junit.jupiter', name: 'junit-jupiter-api', version: '5.2.0' testCompile group: 'org.junit.jupiter', name: 'junit-jupiter-params', version: '5.2.0' testRuntime group: 'org.junit.jupiter', name: 'junit-jupiter-engine', version: '5.2.0' testRuntime("org.junit.platform:junit-platform-launcher:1.1.1") testCompile group: 'org.powermock', name: 'powermock-api-mockito2', version: '2.0.0-beta

How to use different webdrivers based on environment

╄→尐↘猪︶ㄣ 提交于 2019-12-13 03:53:46
问题 I use selenium-jupiter. I am getting a webdriver from method arguments like this: @Test public void testWithChrome(ChromeDriver chromeDriver) { chromeDriver.get("someUrlHere"); } Now I want to run tests on grid so I need to use webdriver based on environment. For example when developing tests on my PC I want to use (local) ChromeDriver, but when running tests on grid with Jenkins, I want to use RemoteDriver. So I need something like this: (That gives me local Chrome when env = 0 or gives me

SystemOutRule in JUnit test didn't capture standard output

断了今生、忘了曾经 提交于 2019-12-13 03:49:58
问题 I want to test ClientDtoServiceConsoleImpl.displayAllClientsInfo() method. It simply prints some data to console. I tried to capture output in unit test by SystemOutRule, but got empty String output . Why? package com.example.services.dto; import com.example.dtos.AccountDTO; import com.example.dtos.ClientDTO; import org.junit.Rule; import org.junit.contrib.java.lang.system.SystemOutRule; import org.junit.jupiter.api.Test; import java.time.LocalDateTime; import java.util.ArrayList; import java

MiniDFSCluster UnsatisfiedLinkError org.apache.hadoop.io.nativeio.NativeIO$Windows.access0

前提是你 提交于 2019-12-12 23:29:07
问题 When doing: new MiniDFSCluster.Builder(config).build() I get this exception: java.lang.UnsatisfiedLinkError: org.apache.hadoop.io.nativeio.NativeIO$Windows.access0(Ljava/lang/String;I)Z at org.apache.hadoop.io.nativeio.NativeIO$Windows.access0(Native Method) at org.apache.hadoop.io.nativeio.NativeIO$Windows.access(NativeIO.java:557) at org.apache.hadoop.fs.FileUtil.canWrite(FileUtil.java:996) at org.apache.hadoop.hdfs.server.common.Storage$StorageDirectory.analyzeStorage(Storage.java:490) at