Questions tagged [junit5]

1

votes
1

answer
170

Views

JavaMelody brakes Spring Boot tests

The application is developed on Spring Boot 2.0.1. I include the next dependency to be able to use JavaMelody - dependency('net.bull.javamelody:javamelody-spring-boot-starter:1.72.0') JavaMelody configuration: javamelody: advisor-auto-proxy-creator-enabled: false init-parameters: url-exclude-patter...
AlexSmith
1

votes
0

answer
338

Views

Test reports is missing in Jenkins

When my build failed - test report is missing in Jenkins. What do I do wrong? This is part of my jenkinsfile: node { stage('Integration tests') { git url: 'https://$autotestsGitRepo', branch: 'develop',credentialsId: gitlabCredentialsId sh 'chmod +x gradlew && ./gradlew clean test step([$class: '...
Poet_peselnik
1

votes
0

answer
1.2k

Views

Gradle, Kotlin, Junit5 and Jacoco - 0% coverage reported

We would like to use Gradle in conjunction with Kotlin and Jacoco (+JUnit 5) for generating a code coverage report. Our project directory tree looks as follows: project/{src,test}/main/kotlin ... Our build.gradle file looks as follows: jacoco { toolVersion = '0.7.9' reportsDir = file('$buildDir/repo...
Julian
1

votes
0

answer
133

Views

Download file from SFTP using SSHJ and put in project classpath and allow MSSQLServeContainer to load it

am working with docker to run my DAO unit test which hits the SQLServer database which resides in the docker container. STEP1: i want me to pull the latest BAK file from my remote server(Linux box in which the docker was installed) to my project class path(src/test/resources) so that i can use the M...
Pradeep
1

votes
0

answer
438

Views

SpringBootTest JUnit Test for DAO fails

I use for the prod a Postgresql database with params stored in application.properties under src/main/resources like follow spring.datasource.platform=POSTGRESQL spring.datasource.driver-class-name=org.postgresql.Driver spring.datasource.url=jdbc:postgresql://localhost:5432/db_prod spring.datasource....
alveomaster
1

votes
0

answer
207

Views

Java GC Overhead Limit Error Using JUnit 5 TestFactory With large stream of dynamicTest (DynamicContainer / DynamicNode)

I am facing the below issue when trying to create and run a large number of JUnit 5 dynamic tests using maven-surefire-plugin 2.21.0 [ERROR] GC overhead limit exceeded [ERROR] org.apache.maven.surefire.booter.SurefireBooterForkException: There was an error in the forked process [ERROR] GC overhead l...
willsteel
1

votes
0

answer
137

Views

Testing Spring Retry Circuit Breaker

I am using Spring Retry Circuit Breaker in one of my Spring Boot applications as: @CircuitBreaker(include = CustomException.class, maxAttempts = 3, openTimeout = 2000L, resetTimeout = 4000L) StudentResponse getStudentInfo(String studentId) { StudentResponse res = studentRepository.getInfoByStudentId...
user3641643
1

votes
0

answer
64

Views

JUnit5 mixed logs with parallel execution

I'm migrating to JUnit5 (5.3.0-M1) and Log4j2 (2.11.0) and I'd like to know if there is an easy way in to handle the logs from different threads. In my previous version I could solve it with a CustomFileAppender, but now I think there might exist some better solution... the idea is to move from some...
jmrg82
1

votes
1

answer
74

Views

how to change csvparsersettings of junit parameterized tests using @csvsource

Given a simple test-method, annotated as @ParameterizedTest, employing input via Annotation @CsvSource ([email protected]({ '@', '*', '#', '?', '-', '$', '!', '0' }). When running said test, the test interrupts as soon as '#' is supposed to be tested. When reading through the stacktrace/exception, I fo...
Navid Noor
1

votes
1

answer
451

Views

Parameterized beforeEach/beforeAll in JUnit 5

I want to write a test for a small database-like application. This application uses queries and a query should return the correct result. This is easily implemented in JUnit 5, something like @BeforeEach void before() { database = prepareDatabase(); } @Test void testQuery1() { assertThat(database.qu...
CoronA
1

votes
1

answer
3k

Views

How to make Spring's @Autowired to work in JUnit 5 extensions? [duplicate]

This question already has an answer here: JUNIT 5: Inject spring components to custom TestTemplateInvocationContextProvider 1 answer I have a Spring Boot application, and I am trying to use @Autowired in a JUnit 5 extension. However, I cannot get it to work. (The @Autowired field is null.) Can anyb...
1

votes
1

answer
86

Views

Unable to create session while mocking Appium's behavior using WireMock

I am trying to mock Appium’s behavior using WireMock. Problem I am facing is: my POST stub is able to respond me with the response code I have set (which I have monitored using Wireshark), but it is throwing exceptions related to session creation. POST stubs I have tried for creating session for r...
Apoorva
1

votes
0

answer
270

Views

Eclipse Photon doesn't recognize my Junit 5 tests for 'Run As'

Assuming I have a simple test: import org.junit.jupiter.api.Test; public class MyTest { @Test public void test() { } } With only JUnit5 as a dependency org.junit.jupiter junit-jupiter-engine 5.2.0 test If I click 'Run as' on the class, it doesn't show up the usual 'JUnit test' option. If I manually...
Gábor Farkas
1

votes
2

answer
82

Views

Is there a way to stage data using Maven and Junit 5?

We are using Maven to run JUnit5 functional tests. Most of the tests require data to go through our entire system (a Storm topology) which could take around 1 minute. We need to send some data through and then wait 1 minute before we run the tests. We need to stage the data and then communicate ke...
markthegrea
1

votes
2

answer
304

Views

Log file per JUnit 5 test in order to attach it to the Allure report?

I would like that each JUnit 5 test has its own log4j2 log file. This log file I would then like to attach to the Allure HTML test report. Yesterday I tried two different approaches which I had googled, but it did not work. One was to use system properties in the log4j2 configuration file. But these...
TicTacFreshMint
1

votes
0

answer
352

Views

Junit 5 (Jupiter) status of Test

hello every one i'm using Junit 5 Jupiter and i want to know after each test if it succeeded or fails and use the @AfterEach methods by each test result like if succeeded i will do something but if i fail i will do something else can u help me out .. seems that @rule work for Junit 4 not for Jup...
Doodi Yehezkel
1

votes
1

answer
289

Views

Pact provider tests broken: pactVerificationTestTemplate » PreconditionViolation

I'm quite new to CDC testing and only make my first steps. I've deployed the Pact-Broker (docker-compose), running at localhost:80. The consumer sends the generated pacts successfully to the broker, but it seems that the provider can't get a valid contract (but this is only the assumption). I'm usin...
Tagira
1

votes
1

answer
61

Views

How to programmatically run JUnit DynamicTest, from a Java Application

I'd like to know if it's possible to run JUnit5 DynamicTests programmatically? I have read the article: https://www.baeldung.com/junit-tests-run-programmatically-from-java that shows how to run traditional package/file based tests. I'm able to easily enough create a hierarchy of dynamic tests using:...
cdc
1

votes
0

answer
224

Views

Gradle build comes up with java.lang.NoClassDefFoundError

In a project I am using gradle, Java11, SpringBoot, Junit5. The application is launching without any problem and when I run the unit tests individually everything is fine. However, when I run gradle->build task the following error appears: Task :test FAILED JwtTokenProviderTest > initializationError...
Saeed Afshari
1

votes
1

answer
68

Views

Combine @TestTemplate with @ParameterizedTest?

How can we use Selenium-Jupiter's @TestTemplate (to have it run with different browsers: https://bonigarcia.github.io/selenium-jupiter/#template-tests ) to combine it with @ParameterizedTest (for data-driven testing, e.g. try different credentials, defined in a source, on a login page)? I have not b...
DieterR
1

votes
1

answer
56

Views

Can multidimensional arrays be passed via @MethodSource (junit 5.1)?

I'm trying to pass two-dimensional arrays to a parameterized test. The one-dimensional array works as expected, but junit complains on the second with 'Error resolving parameter at index 0'. Is this not supported or am I using the wrong syntax? (junit 5.1.0) // This is ok static Stream arrayStream1...
Tamás
1

votes
0

answer
165

Views

JUnit Pioneer TempDirectory extension: Failed to resolve parameter

I'm trying to make a tempDirectory using the JUnit Pioneer (version 0.3.0) TempDirectory extension to use in unit tests with JUnit Jupiter API (version >= 5.1.1.). Environment: IntelliJ IDEA 2017.2.4 jdk1.8.0_191.jdk MacOS 10.14.1 import org.junit.jupiter.api.Test; import org.junit.jupiter.api.exten...
Starkadur
1

votes
0

answer
202

Views

@DisplayName not working when tests executed through maven

JUnit5 tests results are not showing the specified @DisplayName when executed through maven. The same test suites show correctly assigned names when run under eclipse (right-click --> Run as... --> JUnit Test). This is an example of implemented tests: @DisplayName(value='prog QA suite') public class...
ilikeblues
1

votes
2

answer
380

Views

java.lang.AssertionError: Status expected:<200> but was:<404> in Junit test

I want to create JUnit test for Rest api and generate api doc. I want to test this code: Rest controller @RestController @RequestMapping('/transactions') public class PaymentTransactionsController { @Autowired private PaymentTransactionRepository transactionRepository; @GetMapping('{id}') public Res...
Peter Penzov
1

votes
0

answer
25

Views

junit5: howto introspect if a test is actually augmented with @Before/AfterEach methods

I'm writing a little extension that tells me in my log when a test starts, so i know which logs are related to which tests: public class LoggingExtension implements Extension, BeforeEachCallback, AfterTestExecutionCallback { protected final Logger log = LoggerFactory.getLogger(getClass()); @Override...
elonderin
1

votes
0

answer
51

Views

What Maven dependency do I need for PowerMockRunner.class

My test case includes the following line. @RunWith(PowerMockRunner.class) Prior to upgrading to Junit 5 (Jupiter), I imported the following import org.powermock.modules.junit4.PowerMockRunner; But now with the later version of Junit, I can't find the dependency to import to incorporate PowerMockR...
Elliott
1

votes
0

answer
30

Views

Excluding a Junit4 test dependency

I have a slightly legacy parent pom (which I cannot un-inherit) with the following snippet junit junit 4.12 test My child project is a brand new project where I want to use only Junit5. However I think because of inheritance the maven surefire plugin 2.22 is running both Junit4 and Junit 5 tests whe...
Kannan Ekanath
1

votes
2

answer
175

Views

How to mock JPA repository's find method in unit tests

I'm trying to UT my little project and I have a problem. My application use a simple Layered Architecture and I can't happen to UT the service Layer. In fact I'm trying to mock the class CrudRepository from Spring-data. I'm trying to mock the method findAll of one of my repository that is extending...
Kyle_jumpen
1

votes
1

answer
230

Views

why auto dependency is error version?(java.lang.ClassNotFoundException: org.junit.jupiter.api.MethodOrdererContext)

I want to know why is not same to junit-jupiter-engine-5.4.0.pom defined. when I explicit declaration junit-jupiter-api and junit-platform-engine version same as junit-jupiter-engine-5.4.0.pom,the problem be solved. pom: org.junit.jupiter junit-jupiter-engine 5.4.0 test problem: junit-jupiter-engi...
skylark
1

votes
0

answer
30

Views

How to run all tests in same webdriver session using selenium-jupiter junit5 extension [closed]

While using Selenium-Jupiter, a custom junit5 extension for Selenium, every tests create its own webdriver session and close it once test complete Any possibility to run all tests in same webdriver session ? Here both tests run in different webdriver sessions. I need to run both in same webdriver se...
Amit
1

votes
1

answer
39

Views

Does JUnit Jupiter's extension auto detection prevent finding tests?

We recently updated to maven-surefire-plugin v2.22.1 and junit v5.4.0 when we found this error: [ERROR] Failed to execute goal org.apache.maven.plugins:maven-surefire-plugin:2.22.1:test (default-test) on project xxx: No tests were executed! (Set -DfailIfNoTests=false to ignore this error.) -> [Help...
jmrg82
1

votes
1

answer
39

Views

Spring boot app not starting with Maven & Karate

I have a code like this and somehow when I am running through Intellij then it is starting the spring boot ConsumeServiceApplication application however when I am running it through maven then it's not starting the same Spring Boot Application. Am I missing anything in pom.xml to add it? import foo....
ernitingoel
1

votes
1

answer
35

Views

Junit5 and Instrumentation Tests running when running unit tests

I upgraded my tests to junit5 now when I run my unit tests it also runs my instrumentation test which of course causes errors as they're not running in a simulator. How do I stop it from running them? I was able to solve some of the errors using @RunWith(AndroidJUnit4::class) but I still have one...
Crash1hd
1

votes
1

answer
41

Views

Cannot add JUnit 5 Test Case

I'm setting up a new project in my coworker's PC in his Eclipse, so we can use Selenium and JUnit 5.4 and Maven, the problem is that option New JUnit Juniper Test does not appear when creating a new JUnit Test Case. I'm using JUnit 5.4 and here is my screen when I try to create a new JUnit test cas...
sdf68dsf7
1

votes
0

answer
27

Views

How to parse JUnit result xml file and get testcase in java code?

Implemented dymanic JUnit5 test using @TestFactory in class Test_XyzDymanic, method testXyzDymanicallly and custom Suite.xml to add multiple test cases which is being parsed at run time. Based on cases in Suite.xml two maps are being fetched mapExpected and mapAcutal which is being compared as asser...
δev
1

votes
0

answer
30

Views

How to properly name unit tests which check for thrown exceptions [on hold]

I am new to unit testing and am looking for some clarification on how to name tests, testing for thrown exceptions. I decided to follow the naming conventions from Roy Osherove: unitOfWork_stateUnderTest_expectedBehaviour So my first approach would be to name the test like this: @Test void squareRoo...
s4pfyr
1

votes
1

answer
42

Views

Mockito: How do unit test void method java mockito?

I have following code I want to unit test: public class TransformarExcel { public TransformarExcel() { //Constructor } public void validarEntero(HttpServletRequest request, HttpServletResponse response, Integer rowCount, String column, String value) { if (value.equals('0')) { generateErrorProcessing...
1

votes
2

answer
1.2k

Views

Upgrade from JUnit 4 to JUnit 5 in intellij with gradle

I want to convert my Gradle project test from JUnit 4 to JUnit 5. As there are a lot of tests, I don't want to convert them all at the same time. I try to configure my build.gradle like this: apply plugin: 'java' compileTestJava { sourceCompatibility = 1.8 targetCompatibility = 1.8 } repositories {...
Thermech
1

votes
1

answer
239

Views

How do I include an AbstractContextLoaderInitializer into my mvc test execution?

Background I'm converting an existing application to using spring web integration tests via MockMvcBuilders.webAppContextSetup(). I have a class Initializer with the following hierarchy: When the application runs, that class is automatically detected and included in the context instantiation by Spri...
Eric Turley
1

votes
2

answer
903

Views

tests for spring boot application are not runned

I am trying to write an integration for Spring Boot application import org.springframework.boot.SpringApplication; import org.springframework.boot.context.web.SpringBootServletInitializer; import org.springframework.boot.autoconfigure.SpringBootApplication; import org.springframework.boot.web.servle...
lapots

View additional questions