Skip to main content

Questions tagged [junit4]

Version 4 of the popular Junit Java Unit testing framework

-4 votes
0 answers
23 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
38 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
23 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
20 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
35 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
25 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 votes
0 answers
73 views

java.util.ServiceConfigurationError: Provider not a subtype

Background: We have a method in a spring boot application which builds a word doc using aspose and converts it to PDF and returns. But before converting to pdf, aspose has to load some Arial fonts ...
mkkr1009'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
12 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
-1 votes
0 answers
48 views

Why is the mock object being null in testing an Abstract Class's Concrete Method

I have an Abstract class CustomerHelper with a concrete method saveCustomerWithoutPF(). I have mocked an object that it calls (from a private method) and returned a value when (using Mockito.when) ...
Yadhu Krishnan's user avatar
0 votes
1 answer
29 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
62 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
1 vote
0 answers
58 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

15 30 50 per page
1
2 3 4 5
278