Questions tagged [unit-testing]
Unit testing is a method by which individual units of source code are tested to determine if they are fit for use.
1,810 questions
0
votes
2
answers
151
views
Is integration-testing all services the best approach?
I am building an API project, where I have a controller called C1, which calls service S1. Within this service, there are multiple method invocations to services S2and S3 and S4, as well as a call to ...
5
votes
5
answers
616
views
Is it good practice to check exception messages in unit tests? [duplicate]
Imagine I have a function like this (written in Java):
void sayHello(String firstName, String lastName) {
if (firstName == null) {
throw new IllegalArgumentException("first name is ...
0
votes
1
answer
87
views
Automated Testing classes with an injected DbContext [duplicate]
I've been working on an implementation of a service, and have found that there are a number of operations where I need to read from a database to provide a caller with certain data or objects.
In-line ...
1
vote
1
answer
257
views
OO design - Process that relies on the current state of objects
We have a CAD software extension, where you can draw products like walls, doors, windows, etc., and you can export the drawing as an order, which contains the parts and costs.
As part of this export, ...
0
votes
3
answers
206
views
In unit testing, what is the difference between the arrange step in the AAA-pattern and a fixture?
When writing unit tests, I always doubt whether I should put preconditions into the unit test itself (as the "arrange" step) or in a fixture. Is there a difference between the two? When ...
4
votes
3
answers
320
views
The applicability of functional core - imperative shell to a cli program which contains a wrapper around a binary
Not long ago while I was exploring for solutions to test without mocks I've found out about the functional core, imperative shell architecture. It sounds great, I also think that it would play nicely ...
2
votes
2
answers
164
views
Test a script reading from external source
I regularly write scripts and small tools that read data from external servers.
I am still not sure what is the most efficient and effective way to test them:
Probably the most effective way would be ...
4
votes
4
answers
249
views
Modeling superstate and substate combinations in DDD
I am designing an analytics application using domain driven design and test driven development.
I am having difficulty modeling the following requirement:
The application shows a workitem's state. ...
9
votes
10
answers
2k
views
Efficiency of improving testability versus adding unit tests
My team is going to add unit tests to old code without modifying it, to pave way for future design improvements. One of the short term goals is to also reduce the number of newly introduced bugs, ...
1
vote
5
answers
561
views
Code reusability/inheritance introduces pointless testing
Say I have a bunch of classes that imitate cars: SportsCar, Truck, and SUV. All of these classes share some public methods like start() and stop() which they inherit from an abstract class Car. While ...
2
votes
4
answers
201
views
Is it possible to do black box tests when I inject dependencies in the class?
This is my case.
I have a class in which I inject a service as dependency, an IService.
I want to test one method of this class. This method use one of the methods of the service.
Now I want to test ...
4
votes
3
answers
909
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(...
1
vote
2
answers
252
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 ...
13
votes
10
answers
4k
views
Does unit testing spot bugs that QA testing typically does not?
By QA testing I mean like say integration testing, system testing, regression testing, user acceptance testing and the like. If unit testing is skipped altogether would bugs that typically are spotted ...
0
votes
2
answers
239
views
Testing C# app backed by MSSQL database and Entity Framework - seeking advices for going with "test double" approach
I am new to C#, and Windows (coming from Python, Linux background). I need to add tests
to an existing C# codebase, which relies on a MSSQL database and Entity Framework.
In my old days when testing ...