All Questions
19,036
questions
0
votes
0
answers
26
views
How to write verify for static methods that have been called [in Mockito Core] [duplicate]
Without using PowerMockito and using Mockito-Core (the version of Mockito doesn't support PowerMockito and I cannot change the Mockito version), How can I verify that a call to a static method has ...
1
vote
0
answers
42
views
SpringBootTest with Togglz
I just recently added togglz to the spring-boot 3.1.9 application, which contains also much stuff like spring-security, spring-data, etc.
Maven dependency:
<dependency>
<groupId>org....
1
vote
1
answer
36
views
I cant init my webclient in a test with mockito
I'm working on a project with java spring boot 2.x and java 1.8. In my pom i got the dependencies of junit 4.13.2 and mockito 3.12.4. When i try to run my test i got the problem that my setup function ...
0
votes
1
answer
49
views
SimpleAgedCache: Why can't I get my SimpleAgedCache to pass its tests?
I'm new to coding and programming, and I found an interesting SimpleAgedCache exercise on GitHub that uses JavaScript. I feel like I've done the correct coding, and the exercise should pass its tests. ...
-1
votes
2
answers
63
views
How to write a unit test with a controller method that has protected code in it [duplicate]
I am trying to write a unit test for the following controller:
@RestController
@RequestMapping(value = ENDPOINT_URL)
public class MainController extends RestControllerBase {
MainService ...
-1
votes
0
answers
504
views
Test cases failing and getting NoClassDefFound Could not initialize class XXX after upgrading Maven to 3.9.6 version
Test class
`@BeforeEach
public void initResource() {
serviceLocator = mock(ServiceLocator.class);
service = mock(Service.class);
resource = new MappedDefaults(serviceLocator, service);
...
0
votes
1
answer
65
views
Asserting availability of SubTypes of T
I would like to assert whether every element of an array is a sub type of a particular class. So I wrote a helper like this:
private <T> void assertContainsAllSubtypes(
List<? ...
1
vote
2
answers
43
views
Is it advisable to repeat an integration test that is used in more than one method?
I'm developing a project. This project has a repository (UserRepository) which is referenced by other parts of the project, I want to know if I have to test the repository method each time it is ...
1
vote
1
answer
23
views
Java unit test failing due to null KeyHolder
I'm creating new unit tests for an application and I'm stuck because the KeyHolder is not returning a valid object.
For context, here are my classes:
ScriptDao class:
@Repository
public class ...
-1
votes
0
answers
22
views
java.lang.RuntimeException: Could not setup GlassFish Embedded Bootstrap
I have a deployment class for integration tests in my project that is inheriterd by every test class. This class is annotated by:
@ArquillianSuiteDeployment
@RunWith(CustomArqullianRunner.class)
I'm ...
0
votes
0
answers
32
views
In Java, using Mockito fails to initialize MockMaker plugin
When I try to run this code:
package __6__240703.test.user_repository;
import static org.mockito.Mockito.*;
import static org.junit.jupiter.api.Assertions.*;
import __6__240703.main.user_repository....
0
votes
0
answers
26
views
mockito, mock new file or mock file.exists() [duplicate]
Prerequisite: Powermockito cannot be used and the original code cannot be changed.
how to let
File file = new File("xxxx");
file.exists() returns true.
public void testFile(String path) {
...
0
votes
0
answers
23
views
How to pass a Junit Test for a Primefaces FileUploadEvent
i have a doubt about how to pass a JUnit test for a Primefaces FileUploadEvent.
The methods is this:
public void cambiarLogoCrear(FileUploadEvent event) {
cambiarLogo(event, false);
}
private ...
-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 ...
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-...