Linked Questions
14 questions linked to/from What should you test with unit tests?
2
votes
3
answers
2k
views
Should all possible counter-cases be tested? [duplicate]
I'm currently trying to unit test a behavior which, in some very particular cases, returns B instead of A. It may depend on the value of 3 different attributes for example.
How should I test this?
...
1
vote
1
answer
6k
views
Multiple methods in single test case [duplicate]
I am new to Junit. I have a class with four methods. I am creating a test class with test cases. Can I have a test case that uses more than one methods of testing class or there should one test case ...
0
votes
1
answer
420
views
Handling repetitive unit testing tasks [duplicate]
This problem arose whilst writing a simple 3D vector class.
The class contained methods (Java, so no operator overloading) for addition, subtraction, multiplication, and division. These methods ...
1
vote
0
answers
67
views
How many tests cases should there be for a method? [duplicate]
Unit testing has been widely lauded as an indispensable part of software development, and TDD has many proponents.
However, due to the combinatorial nature of various pieces of code, it can be ...
31
votes
4
answers
3k
views
Unit testing best practices for a unit testing newbie
In recent years, I have only written small components for people in larger projects or small tools. I have never written a unit test and it always seems like learning how to write them and actually ...
0
votes
11
answers
990
views
Testing : Why is it necessary?
Hello I will try to explain what is my actual understanding of tests and why I have problems to grasp it's utility.
Even if I try my hardest to understand the concept of TTD, unit test, integration ...
12
votes
3
answers
1k
views
Unit Testing Competition
My employers runs a monthly unit testing day competition. One entire day is dedicated to writing unit tests -- obviously we do more testing throughout the month, but this is an entire day -- and the "...
6
votes
3
answers
1k
views
Do people use unit testing to formalize assumptions in code?
One of the things I struggle with when unit testing is deciding what behaviors to actually test. I think part of my struggle stems from how most unit testing tutorials don't use good examples of ...
2
votes
2
answers
614
views
Unit testing and reality [closed]
I m actually studying Unit testing, reading some articles on the internet and trying to understand how it works exactly, but it's not very clear for me actually.
What should I test ?
I have seen ...
5
votes
2
answers
436
views
Unit tests tactics
The only unit tests tactic I'm familiar with is comparing against golden data _ a predefined set of input data for which output is known (preferably including corner cases).
I cannot think of any ...
6
votes
2
answers
545
views
Is it ok to write "extra" unit tests?
My understanding of how TDD should work is that you write a failing test for the next bit of functionality you want to add to a function or object, code until the test passes and then write the next ...
3
votes
3
answers
240
views
Do tests that asserts a user can't do an action have any value?
Given a system with static permissions (1 permission for every action that can be made: create a resource, update a resource, etc), and dynamic roles (can be created and assign permissions to it ...
1
vote
4
answers
1k
views
Looping Exhaustive Test Cases - A Good Practice?
Sometimes we have code like this:
private static final List<Goat> INEDIBLE_GOATS = [GOAT_A, GOAT_B, GOAT_C]
void eatGoat(Goat goat) {
if(INEDIBLE_GOATS.contains(goat)) {
throw new ...
0
votes
0
answers
51
views
Unit testing multiple values [duplicate]
If I create a function to calculate the square root of a number, I suppose i should write a single unit test (maybe two, to test how it handles negative numbers).
But what if I have a function which ...