Skip to main content
Filter by
Sorted by
Tagged with
1 vote
1 answer
62 views

ApplicationContext not loading in Junit 4 test case after upgrading to spring-boot v3.2.10

This used to work in spring-boot v2 but after upgrading to spring-boot v3 test case gives error. The @Value annotation is not picking the right value from application.properties file because the ...
Abhishekj2096's user avatar
0 votes
0 answers
20 views

Mocking Cache Config class failing

I haven't mocked the configuration class for cache config properties. Can someone help me with possible unit tests for this cacheable layer ? CacheConfig.java import com.github.benmanes.caffeine.cache....
TechGeek's user avatar
  • 508
0 votes
0 answers
29 views

Osgi framework bundle junit execution issue .junit.platform.commons.JUnitException: TestEngine with ID 'junit-jupiter' failed to discover tests

I am upgrading my application with latest equinox osgi version and getting below error while executing test cases. What I understood from multiple sources that this is related to org.junit.jupiter.api ...
user3520253's user avatar
0 votes
1 answer
63 views

How to write a tests for PickVisualMediaRequest, in android studio?

I have a fragment in my app that requests the user to upload an image. How can I write a Junit test that runs on the emulated device that would select and image from the pop up? I am also wondering if ...
Griffin Frankiw's user avatar
0 votes
0 answers
55 views

JUnit 5 + Mockito tests are significantly slower compared to JUnit 4 – how to optimize?

I'm migrating our tests from JUnit 4 to JUnit 5, and I'm noticing a substantial increase in execution time for tests using Mockito. Specifically, empty tests take almost 100 times longer with JUnit 5. ...
Mathias Pichler's user avatar
1 vote
0 answers
50 views

Mockito Exception for mocking interface HttpServletRequest

org.mockito.exceptions.base.MockitoException: Mockito cannot mock this class: interface javax.servlet.http.HttpServletRequest. Mockito can only mock non-private & non-final classes. If you're not ...
Ranjani-devz's user avatar
0 votes
0 answers
22 views

Not getting the exception, scenarios details in console while running runner file as junit test. Working fine when run as cucumber feature

cucumber feature: Feature: feature to test login functionality Scenario: Check successful login with valid credentials Given user is on login page When user enters username and ...
Tony's user avatar
  • 1
0 votes
0 answers
22 views

(Android Studio Tests) Error: Could not find or load main class Files\NVIDIA

I'm developing an application in Android Studio for Windows. When attempting to run one of the JUnit4 tests I've created, I get this error: > Task :app:testDebugUnitTest FAILED Error: Could not ...
BetaBites's user avatar
0 votes
0 answers
75 views

Tests broken for IntelliJ Spring Service after updating dependencies - legacy code

I have a legacy Spring Service that I am trying to update to remove a log4j vulnerability. I have updated the relevant dependencies/code and my project builds, compiles and runs successfully. However ...
Mathew's user avatar
  • 3
0 votes
0 answers
28 views

Android FragmentScenario androidTest prevent running network calls on launch and view model testing

I have an existing fragment class as part of a navigation graph component and uses Dagger to create instances of ViewModels scoped to the nav graph. However, I have a few questions about ...
MajinKenn's user avatar
0 votes
0 answers
47 views

JUnit test suite @IncludeTags is also running JUnit4 tests without @Tags

I want my test suite to only run the @Tagged tests and ignore the ones annotated with @RunWith. I have JUnit 4 and 5 tests. I have a test suite that uses @IncludeTags("myTag"). I have JUnit5 ...
BlairCalgary's user avatar
0 votes
1 answer
20 views

Unit-tests exhibiting 'state' across test-methods after moving from JUnit4 to TestNG

The legacy project I'm working on uses both JUnit4 and TestNG testing frameworks and for reasons beyond my control I cannot upgrade to JUnit5. While all new test-suites (classes) that we create are ...
y2k-shubham's user avatar
  • 11.4k
1 vote
0 answers
42 views

I want to understand test result format of Junit in VS Code

In VS Code, using JUnit. I am testing addition() method of calculator class. I have used assertEqual method to compare expected result and actual result. This is my code for test method: @Test ...
Devangi Kotak's user avatar
0 votes
0 answers
68 views

How to test a Quarkus application with JUnit 4?

I’m porting an application to Quarkus, and am now updating its tests to use Quarkus as well. I could port successfully the JUnit 5 tests using @QuarkusTest and @TestHTTPResource: package com.example....
Nicolapps's user avatar
  • 991
0 votes
1 answer
56 views

Is there a replacement for assumeThat in JUnit 5?

I am migrating code from JUnit 4 to JUnit 5. Is there any replacement for the method Assume.assumeThat?
LoPoBo's user avatar
  • 1,837
1 vote
0 answers
107 views

execution failed for task ':app:connecteddebugandroidtest

My instrumentation test is not executed in the device after the test and app install. The test sometimes keep "building" for long times +15min Here is the logcat with warnings and info ...
user avatar
-1 votes
1 answer
65 views

Unit test for Lambda expression

I am trying to write a unit test (using Mockito) for my Spring Security config class and it has this code @Bean public GrantedAuthoritiesMapper authoritiesMapper() { return (authorities) -> { ...
XAJA's user avatar
  • 37
1 vote
0 answers
23 views

how to spy/argumentcaptor of background thread to verify in karate-spring boot application

I've a scenario, API service running in springboot and trying to port the existing functional Test to karate based testing. I've added. the API endpoint based configuration and other validation for ...
Krish S's user avatar
  • 11
0 votes
1 answer
37 views

NoMatchingViewException error during Espresso test

I am doing an instrumentation test of Fragment is displayed or not. When I start the test it execute, I am able to see FragmentLogin view in physical device but test fail by saying androidx.test....
Dnveeraj's user avatar
  • 138
0 votes
0 answers
27 views

I'm trying to work testcode about Java Spring Boot 6.x Websocket code with STOMP but in trouble

public class WebSocketIntegrationTest { @LocalServerPort private int port; @Autowired private MockMvc mockMvc; @Autowired private ObjectMapper objectMapper; private ...
Buddhaman's user avatar
0 votes
0 answers
54 views

Why are tests running successfully when running as Junit test but when building the pom file, there are test failures and build failure?

I dont have any error and tests run successfully when its run as Junit. But on Building that project's pom, the following error is coming and the build is being failed because of these test failure. ...
DropKick's user avatar
0 votes
0 answers
19 views

Android - DND permission from Unit tests

I'm writing unit tests to test the notification service layer. So while testing out the create channel feature, I would like to test all of the properties of the NotificationChannel object. Hence, I'm ...
Mano's user avatar
  • 730
0 votes
0 answers
47 views

How to write test cases where the mocked objects are not giving anything back

How to write assert or verify for these. I cannot change the code in any way. Only Junit can be written by me. public void Calculator(booker, product) { Matcher matcher = buildCriteria(product); ...
DropKick's user avatar
0 votes
1 answer
41 views

JUnit 5 - Migration - Custom test annotation no longer detected?

I had the following custom test annotation that worked in JUnit4 that IntelliJ and JUnit no longer wants to recognize: @Target({ElementType.METHOD, ElementType.ANNOTATION_TYPE }) @Retention(RUNTIME) ...
David S's user avatar
  • 187
0 votes
0 answers
34 views

Maven Test runs indefinitely on a Test Suite which executes fine in Junit4

I recently mavenized few old projects. When I am trying to build caffeine tests project with maven build, the test suite hangs when it executes the first test. I debugged the application, it adds all ...
Vishnu Ramesh's user avatar
0 votes
0 answers
39 views

How can i check that exception was thrown and handled in Junit4/Mockito?

I'm writing tests using Junit4 and mockito and wondering if there is a possibility to check if specific exception was thrown and handled inside tested method. What I mean is - I have for example ...
r17's user avatar
  • 1
0 votes
0 answers
49 views

InvocationTargetException when using PowerMockito to test Static Methods

I have a final class ConfigurationManager that has a method getProps(CONF). I have to mock and return "true" when this method is called. public final class ConfigurationManager { ...
John K Jose's user avatar
1 vote
0 answers
49 views

How to mock a final class to do nothing when a method from a final class is called using Mockito?

How to mock a final class to return nothing when a function from a final class is called? In test method: @InjectMocks CustomerService customerService; @Mock AddCustomerProfile addCustomerProfile; @...
John K Jose's user avatar
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
1 answer
49 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
0 answers
15 views

JUnit4 use @RunWith(Suite.class) and @RunWith(SpringJUnit4ClassRunner.class) together

I have a set of Integration Tests which I want to run in suite. As of now all IT have runner annotated @RunWith(SpringJUnit4ClassRunner.class). Also I have used test containers for Postgres and ...
pankaj_ar's user avatar
  • 765
0 votes
0 answers
75 views

How to throw exception with super constructor been mocked

I have an exception class public class FooStudioException extends SpamException { public FooStudioException(String message, String localizedMessage, Throwable cause) { super(...
Abhijit's user avatar
  • 63.6k
1 vote
0 answers
112 views

Mockito.mock(...) does not work inside an Arquillian integration test anymore

We're upgrading from Java 8 to 21 and since we run Arquillian with a remote Wildfly for integration testing, but also have some mocking inside those test classes to avoid to execute some annoying code,...
MJCM's user avatar
  • 53
0 votes
1 answer
30 views

fill @value variable in a test

I want to test this KeyStoreConfig class but what ends up happening is jceksFileLocation is always null and returns an error What can I do to test this class thoroughly. If I could somwhow populate ...
Juicy Jay's user avatar
  • 109
0 votes
1 answer
46 views

getInputStream() of a mock Socket returns a null object

I'm writing a junitTest that should test a serverHandler object that handle the reciving and sending of message to a server. I'm doing that by mocking the socket of the server and putting my own ...
Samuele's user avatar
  • 11
0 votes
0 answers
43 views

Unable to read a PDF from NAS (network file share) on windows

We were trying to write Junit test cases for our code that uses AEM packages for Assembler service, Output service and PDF generator Service. Our code tries to calculate the number of pages in a PDF ...
Abhi's user avatar
  • 1
0 votes
1 answer
56 views

How can I control which class will be inject using @AutoWired when writing unit tests?

I have a class like below class Foo{ @AutoWired private Bar bar; @AutoWired public Foo(List<Baz>){ // do something with Baz } how can I control which Baz will be injected, like only ...
Frank Bao's user avatar
0 votes
1 answer
60 views

Selenium WebDriver used to open chromium with `mvn test`, but does no more

I started a Selenium + JUnit 4 Test from the two getting started documents. I am on Maven3, Java17 and IntelliJ IDEA w/ Arch Linux. My pom.xml is as follows: <?xml version="1.0" encoding=&...
Leder's user avatar
  • 382
0 votes
1 answer
187 views

How can I mock a super class and suppress calls to the actual super class constructor using mockito-inline?

I've seen some old questions about using the regular mockito mock maker. i.e. using the mockito-core dependency. I think this is not a duplicate because I'm using the new inline mock maker from ...
majinnaibu's user avatar
  • 3,012
0 votes
1 answer
47 views

Is it possible to specify multiple annotations into the --test-targets command

According to the firebase documentation I should be able to specify multiple test target filters - https://cloud.google.com/sdk/gcloud/reference/firebase/test/android/run#--test-targets I've specified ...
Boyana Staneva's user avatar
0 votes
0 answers
35 views

(although at least one Creator exists): no int/Int-argument constructor/factor -

Service Class: import com.google.cloud.bigquery.FieldValueList; import com.google.cloud.bigquery.QueryJobConfiguration; import com.google.cloud.bigquery.TableResult; private ItemCurResponseDTO ...
PAMPA ROY's user avatar
0 votes
0 answers
28 views

Android: Junit test to check/validate file inside Assets folder throw FileNotFoundException

I have abc.json file inside Assets folder of the Android project. Everything is working in the application. i.e, able to read this file when launching the app on the phone. Junit test to validate the ...
Vinit ...'s user avatar
  • 1,459
0 votes
0 answers
135 views

How to run failed/flaky tests using gradle.test-retry

inside build.gradle plugins { id 'org.gradle.test-retry' version '1.0.0' } test { retry { failOnPassedAfterRetry = true maxFailures = 3 maxRetries = 2 } } i ...
abhisekh's user avatar
0 votes
0 answers
153 views

Failing to load ApplicationContext for @DataJpaTest

I have a Jhipster project that uses spring boot 1.5.12.RELEASE and I want to add tests for the repositories using @DataJpaTest. There are also some ITs in the project without @DataJpaTest and ...
Tom's user avatar
  • 171
0 votes
0 answers
24 views

Execute JUnit suite with Maven Fork in Customized runOrder

I'm using JUnit to run my integration tests along with maven-surefire. I've a suite with 300+ tests to be executed and forks are used to avoid sharing resources. There are few tests which run for ...
user23866018's user avatar
2 votes
2 answers
390 views

Unit Testing StateFlow Created By StateIn

I have a viewmodel class that uses a StateFlow that is created using the StateIn operator. I.E. private val _state = MutableStateFlow(MyState()) private val myItems = myRepository.myFlow.stateIn( ...
tomerpacific's user avatar
  • 6,179
0 votes
0 answers
30 views

Getting NestedServletException while mocking Resttemplate object in Spring Boot

The controller class looks like this: @RestController @RequestMapping("/api/tntcalc") public class TransitTimeCalculatorController { @PostMapping("/calculate") // @...
PAMPA ROY's user avatar
0 votes
0 answers
38 views

How to test a Spring method for adding a file to GridFS with JUnit and Mockito?

public String addMaquette(MultipartFile maquette, String keySousRubrique, String projectId, String titrePage) throws IOException { DBObject metadata = new BasicDBObject(); metadata.put("...
ismail fourati's user avatar
0 votes
1 answer
882 views

trying to run in parallel for cucumber junit not working

I added the parallel and threadcount lines to surefire plugin configuration in pom file: <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-...
JustCallMeDan's user avatar
0 votes
1 answer
109 views

Junit with Mockito for java

I am learning java and exploring junit with Mockito. The idea is to understand where and how to use mockito and learn how to write junit tests. Im a beginner and learning. How can i write a junit test ...
User1515's user avatar

1
2 3 4 5
84