All Questions
82 questions
4
votes
3
answers
320
views
Clearing static state before testing each method
My SUT class depends on external static state (which generally should be avoided, I know).
How do I make sure my tests do not depend on their order of execution?
I mean other by introducing some reset(...
0
votes
0
answers
70
views
Is Spring Boot Unit Test Coverage with Integration tests only a bad practice?
I have recently come across a few codebases at work where the previous developers chose to reach the >80% coverage criteria by writing only integration tests with the @SpringBootTest annotation ...
1
vote
2
answers
260
views
How should you test classes that access localized properties?
Suppose you have a class that accesses a property (perhaps, it's a GUI class)
How do you test it in Java?
You can inject (and mock) a ResourceBundle
import javax.swing.JLabel;
import java.util....
1
vote
2
answers
263
views
End2End/integration Testing in Java with Selenium - how to get a good test structure - looking for experiences [closed]
At work I am currently tasked to implement End2End/integration Tests for one application using Selenium.
we have an project consisting of a frontend and multiple backends (spring-boot apis). The ...
0
votes
2
answers
758
views
Should Value Objects be used inside the DTO?
After reading about Value Objects, I think they're pretty cool and should be used, but I am not sure if I am doing it the right way.
Let's assume that I have a simple DTO to create a user, which ...
0
votes
3
answers
434
views
Would you test this piece of configuration code? How do I determine which code is worth testing?
We have a piece of code that decorates an interface to transparently add retry logic.
Inversion of Control configuration
service.AddOurRestApiClient()
.AddResilienceHandler("Retry", ...
0
votes
1
answer
1k
views
Mock a bean with 10 methods when I only use one?
I face some situations similar to the following simplified one:
@Component class ServiceOne {
@Autowired ServiceTwo two;
void act() {
...
two.a();
...
}
}
@...
1
vote
4
answers
4k
views
Should test resource files be stored inside the Java class source directories?
In a TDD (Test-Driven Development)-based Java project built by maven, lots of classes needs to be tested with text-based input files such as .csv. At the beginning, I put them into the src/test/...
0
votes
1
answer
404
views
Should i specify that my methods "throws ConstraintViolationException" if the exception is actually thrown by a CDI interceptor?
Here is a sample method:
@ApplicationScoped
public class MyClass{
public void getUser(@Min(1) int id){
//get User logic
}
}
I'm in a CDI environment with @ValidateOnExecution(type = ...
1
vote
2
answers
531
views
How to avoid unit test duplication in wrapper classes?
Assuming I’ve a class with three methods, startCollection, add, endCollection.
One test case is: if start was not called, add should return an error.
I’ve mocked the persistency storing the state with ...
0
votes
2
answers
104
views
How to cover by tests HTTP API wrapping library
As mentioned in title, I don't understand how I supposed to cover by tests code which is just wrap http api.
I guess I can write only unit tests, because wrapped service is paid. Integration tests in ...
0
votes
1
answer
2k
views
Java: Splitting a large unit test class
The project (Java/Spring) I currently work on has a rather large unit-test class for one of its services : more than 1000 lines, several Nested class (one per big functionality), some tests without a ...
6
votes
1
answer
16k
views
Should I mock ObjectMapper in my unit tests?
I have different services in a spring application that have a dependency on Jackson ObjectMapper, the unit tests rely on @InjectMocks to inject all the various dependencies to the class that is under ...
3
votes
4
answers
1k
views
How do I deal with the fact that I am forced to make helper functions public for testing purposes?
I've encountered several scenarios that require me to mock certain helper methods because they call outside resources. As a result, I'm forced to convert all my helper methods from private into public....
-4
votes
2
answers
191
views
An idea about cooperation between development engineers and test engineers
Suppose we want to develop a small module (time needed: two weeks of one developer). Then what about this new (maybe?) pipeline:
The test engineer starts working:
Think about all cases (including many ...