All Questions
Tagged with junit unit-testing
5,144
questions
1
vote
0
answers
27
views
JerseyTest and Mockito - problem with mocking an object
My aim is to learn a little bit about mocking objects in the context of Jersey Test.
I have 3 classes:
ServiceController
package com.vogella.jersey.first;
import javax.ws.rs.*;
import javax.ws.rs.ext....
0
votes
0
answers
23
views
ParameterizedTest JUNIT5 with suspend functions
I'm trying to clean a little bit my code and when testing my datasource I'm repeating a lot the test that returns connection and service error, and I'd like to have a bunch of code that 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 ...
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
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 ...
-1
votes
1
answer
32
views
Mocking the new instance creation call inside a void method without using PowerMock
I have a class where inside a void method it does a new instance creation
public class BaseDao {
protected void setDataSource(DataSource dataSource) {
this.defaultTemplate = new ...
1
vote
2
answers
124
views
Testing Dispatcher IO and ViewModelScope in Unit Tests
I'm trying to test some code in my viewmodel. I'm trying to make two network calls with dispatcher async, but haven't figured out how to test. This is a simplified example of what I'm essentially ...
0
votes
0
answers
22
views
Unit testing class with flow collection in init
How can I best go about unit testing flows that are collected in a class's init function?
The only solution I've come up with so far requires hard-coded delays.
Consider a sample implementation of a ...
1
vote
1
answer
45
views
How to AssertEquals 2 object arrays (both with an array field)
I am trying to assert that 2 arrays of a UserDto object are equal to one another in a unit test that I am implementing. See below my UserDto class and the 2 UserDto instances I am trying to compare
...
1
vote
2
answers
43
views
Run JUnit tests from multiple projects at once
I have a repository of projects, each containing JUnit tests. I am looking for either a method or a framework to run them all at once, instead of manually running for each project.
After some research ...
0
votes
1
answer
19
views
how can i take access to test method like AbstractClass.InnerClass.fun
I'm trying to write unit test for Abstract Class Realization and I need to write test for method with path Class.InnerClass.fun. example InClass.b2:
package com.example.kotlin_spring
abstract class ...
-1
votes
3
answers
83
views
doNothing when on abstract class method but should work when called from concreate class instance
I have following structure:
class Sample {
private Map<String A> serviceMap;
@Autowired
private List<A> services;
@PostConstruct
public void init() {
this.serviceMap = this....
0
votes
1
answer
32
views
JUnit Testing Multiple Values Against Same Function Best Practice
Say I have various input strings that are passed into the same function and returns output strings that are compared against their expected results. For example, periods should be transformed to ...
3
votes
1
answer
35
views
Test Coverage for DB call java code after couchbase 7.2 upgrade
We have recently upgraded Couchbase DB from 6.x to 7.2 . Which introduced collection and scope along with bucket. That means this
GetResult serviceInventoryJsonDocument = this.bucket....