Skip to main content
The 2024 Developer Survey results are live! See the results

Questions tagged [junit]

Popular unit testing framework for Java and Scala. The latest version, JUnit 5, supports rich annotation-based and parameterized tests. Consider using in conjunction with the Java or Scala tag to indicate your use case.

0 votes
0 answers
46 views

When I perform spring-boot unit testing, the spring datasource is repeatedly initialized

I'm using Groovy + Spock to perform unit testing for a Spring-boot project. I have two test classes, Test Class A and Test Class B. These two test classes are independent and have no dependency ...
Mike Wu's user avatar
0 votes
1 answer
46 views

Yet another "No tests found" question (testDebugUnitTest). Did I miss a dependency somewhere? Trying to use JUnit5

I've made my first android app (a very simple button tapper) and am currently trying to create test files for it. I've been following the YouTuber Philipp Lackner and have gotten by pretty well ...
zecuse's user avatar
  • 167
-1 votes
1 answer
43 views

How to unit test Mapper provided by MapStruct?

I want to unit test my MapStruct mappers, if that is a thing, should I use Mockito, or can I just call mapper = new UserMapperImpl();. UserMapperTest.java class UserMapperTest { private ...
Davido's user avatar
  • 95
0 votes
0 answers
27 views

Maven surefire overwrites the logs for flaky tests on rerunFailingTestsCount

I'm using maven-surefire-plugin to rerunFailingTests for the failing tests. If the test fails in first attempt and pass on the later attempts, the logs(*.txt, *-output.txt) from the /target/surefire-...
KGP's user avatar
  • 350
0 votes
0 answers
29 views

Junit Mockito Testcase for Rest API controller class taking boolean as path parameter

I am new to Junit Mockito testcase. I am trying to write REST API controller class .But facing some issue.Can someone please help me on writing the test case. @RestController @RequestMapping("/...
Deepak's user avatar
  • 11
0 votes
1 answer
49 views

How to use class member variables inside Junit-Mockito tests

class MyClass { MyErrorServiceList myErrorServiceList; // myErrorServiceList is initialized by some complex method calls public boolean processErrorServiceList() { if (...
Henry Passion's user avatar
0 votes
0 answers
22 views

Gradle junitXML system-out at wrong position

I use Gradle and Appium for integration tests. I want to upload the generated junit.xml file to an external tool. For this, I need a specific format for my XML file. Currently, 'system-out' appears ...
Kleifker's user avatar
0 votes
1 answer
37 views

Junit Mockito testcases for Service Layer

I am facing issue while writing junit mockito testcases for the below service layer class. Can someone help me writing the test cases for me. public class BigQueryServiceImpl implements ...
Deepak's user avatar
  • 11
1 vote
1 answer
81 views

Use custom Dockerfile with JUnit testcontainers for OpenSearch

I'm trying to use a JUnit test container for OpenSearch, in Kotlin, with the Spring Boot framework. (Enough qualifiers?) I've been able to get it mostly working, roughly like this: class ...
Crell's user avatar
  • 524
0 votes
0 answers
15 views

Create and write to a real file in JUnit test case

I have a unit test case in Android where I want to create a new file and write data to it. This file needs to be manually analysed later so cannot use TemporaryFolder(). Is there any way to create a ...
Bigbrain Ammamma's user avatar
0 votes
0 answers
31 views

JUnit test to compare specifications

I have a method that creates a Specification from a user role. I am trying to create a junit test to see if the output is well created. In this example I am providing, the user with an IP role, and ...
Robin J's user avatar
  • 33
0 votes
0 answers
34 views

I created a test case method named 'testRegisterCustomerSuccess,' but it encountered issues related to JPA queries

I have a method named registerCustomer in a service implementation class. I created a test case named testRegisterCustomerSuccess for this method in a class named UserServiceImplTest, where I mock ...
Prince Lathiya's user avatar
0 votes
1 answer
32 views

Error occurred prior to updating JUnit 4 to JUnit 5

Before the update, don't run my class RunTest, get a error in execution package automation; import org.junit.FixMethodOrder; import org.junit.runner.RunWith; import org.junit.runners.MethodSorters; ...
Lucas Tenório's user avatar
0 votes
1 answer
26 views

Junit for the elastic search ParsedFilter

I am trying to cover Junit for elastic search ParsedFilter. Code: private void returnDeviceColumnValues(List<String> uniqueColumnValues, NativeSearchQuery searchQuery) { SearchHits<...
bharathi's user avatar
  • 6,161
0 votes
0 answers
27 views

Android test class with time delay

I'm working on an IdleHandler class in my Android app to handle inactivity. The class looks like this: class IdleHandler { object TimerConstants { const val ...
James Ostevik's user avatar

15 30 50 per page