junit4

JUnit AssertionError when testing SimpledateFormat

为君一笑 提交于 2021-02-19 08:20:36
问题 Using JUnit 4.12 and AndroidStudio I am trying to test below method Where results seems to be matching I don't know why as a reesult I am getting java.lang.AssertionError Method under test: public String dateNow() { SimpleDateFormat sdf = new SimpleDateFormat("dd-MM-yyyy_hh-mm-ss"); String date = sdf.format(new Date()); return date; } My test class : private Addons mAddons; @Before public void setUp() throws Exception{ mAddons = new Addons(); } @Test public void testDateNow() throws Exception

Equivalent for @RunWith(JUnitPlatform.class) for JUnit5

老子叫甜甜 提交于 2021-02-19 02:08:55
问题 In my project I'm doing some cleanup and decided to move everything to JUnit5. Till this time, I was using @RunWith(JUnitPlatform.class) Now I want to migrate it to @ExtendWith. Is there any equivalent for this JUnitPlatform.class in JUnit5? 回答1: You don't need it anymore when using junit 5. In the junit documentation it states: Annotating a class with @RunWith(JUnitPlatform.class) allows it to be run with IDEs and build systems that support JUnit 4 but do not yet support the JUnit Platform

maven surefire: when are we forced to set reuseForks=false?

雨燕双飞 提交于 2021-02-19 01:35:33
问题 In my project when I set reuseForks=true then i have to increase the forkCount to number of test classes. Otherwise, It is throwing illegalargument exception. Also, If I set reuseForks=false then it also work fine. Currently I have following configuration because number of test classes are less than 10. <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-surefire-plugin</artifactId> <version>2.18.1</version> <configuration> <reuseForks>true</reuseForks> <forkCount>10<

JUnit test class order

耗尽温柔 提交于 2021-02-17 19:20:14
问题 I have a java app with maven. Junit for tests, with failsafe and surefire plugins. I have more than 2000 integration tests. To speed up the test running, I use failsafe jvmfork to run my tests parallel. I have some heavy test class, and they typically running at end of my test execution and it is slows down my CI verify process. The filesafe runorder:balanced would be a good option for me, but i cant use it because the jvmfork. To rename the test classes or move to another package and run it

Junit 5 looking for actual environmental configuration to run the test

旧巷老猫 提交于 2021-02-15 07:37:16
问题 My project is using spring-boot , sping-data-jpa , spring-data-rest , hibernate I have updated to spring boot 2.3.1 . My previous test cases are on Junit 4 , I am migrating to Junit 5 . When I run my test case with junit 5 it is looking for actual environmental configurations like datasource , hibernate:dialect with Junit 4, it was not looking for it. Please find Junit 4 and Junit 5 test class for comparison Junit 4 Test import org.junit.Before; import org.junit.Test; import org.junit.runner

Gradle fails to build at Test

浪子不回头ぞ 提交于 2021-02-11 17:18:20
问题 I have a spring boot project that has multiple modules each with its own gradle file. Spring boot version: 1.5.2.RELEASE gradle version:3.4 server (which includes main class) and other configurations shared (Utility classes used by other modules) service (module with various repository and services) transaction (module which handles transaction) I need to write test for the project but I cannot change the project structure. I created a test in my transaction module. The parent gradle file is

Gradle fails to build at Test

眉间皱痕 提交于 2021-02-11 17:14:32
问题 I have a spring boot project that has multiple modules each with its own gradle file. Spring boot version: 1.5.2.RELEASE gradle version:3.4 server (which includes main class) and other configurations shared (Utility classes used by other modules) service (module with various repository and services) transaction (module which handles transaction) I need to write test for the project but I cannot change the project structure. I created a test in my transaction module. The parent gradle file is

Gradle fails to build at Test

£可爱£侵袭症+ 提交于 2021-02-11 17:14:13
问题 I have a spring boot project that has multiple modules each with its own gradle file. Spring boot version: 1.5.2.RELEASE gradle version:3.4 server (which includes main class) and other configurations shared (Utility classes used by other modules) service (module with various repository and services) transaction (module which handles transaction) I need to write test for the project but I cannot change the project structure. I created a test in my transaction module. The parent gradle file is

Gradle fails to build at Test

五迷三道 提交于 2021-02-11 17:14:12
问题 I have a spring boot project that has multiple modules each with its own gradle file. Spring boot version: 1.5.2.RELEASE gradle version:3.4 server (which includes main class) and other configurations shared (Utility classes used by other modules) service (module with various repository and services) transaction (module which handles transaction) I need to write test for the project but I cannot change the project structure. I created a test in my transaction module. The parent gradle file is

Unable to initialize Mockito

只谈情不闲聊 提交于 2021-02-10 16:50:35
问题 I am trying to set up Mockito 2.22 and have downloaded mockito-core-2.22.2.jar and byte-buddy-1.9.0.jar and, in the Netbeans 8.2 project, I have added those two jar files, JUnit 4.12 and Hamcrest 1.3 to the test libraries. When I try to run the MCVE: package com.stackoverflow.test; import org.junit.Test; import static org.mockito.Mockito.mock; public class SimpleMockTest { public static class A{ public String value(){ return "A"; } } @Test public void testASimpleMock() { A mocked = mock( A