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

Questions tagged [junit4]

Version 4 of the popular Junit Java Unit testing framework

0 votes
0 answers
13 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
40 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
14 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
  • 700
-4 votes
0 answers
27 views

@Mock is not working after migrated to java 17 [closed]

We was having code with java 11 and powermickito. We have migrated it to java 17. SO @Mock is giving null everywhere. I need to use Mockito instead of powermockito. We are using internal framework for ...
Jyoti's user avatar
  • 1
0 votes
0 answers
40 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
24 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
  • 177
0 votes
0 answers
21 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
37 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
-1 votes
0 answers
15 views

Mock not working after upgrade to JUnit 4.12

I have a mock that worked fine in a previous version of JUnit, but after the upgrade to JUnit 4.12 it won't do the job. I did not changed any piece of code. The mock returns a new object of a static ...
Raul Lazar's user avatar
0 votes
0 answers
28 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
42 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
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
0 answers
11 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
63 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.3k

15 30 50 per page
1
2 3 4 5
278