Linked Questions

4
votes
3answers
588 views

Purpose of unit testing simple methods

I'm trying out unit testing to see if it works for me, but im having trouble with these little functions. public void OpenNewMenuItem(MenuItemID ID, ITab DataContext = null){ var menuItem = ...
1
vote
3answers
293 views

Are unit tests needed for a function that only calls another function?

Assuming OldModule.oldFunc, if we want to move oldFunc to NewModule and, for backward compatibility, keep oldFunc there merely calling NewModule.newFunc by passing the exact same arguments and doing ...
12
votes
2answers
3k views

What kind of code would Kent Beck avoid unit testing? [duplicate]

I've been watching a few of the Is TDD Dead? talks on youtube, and one of the things that surprised me is Kent Beck seems to acknowledge that there are just some kinds of programs that aren't worth ...
2
votes
2answers
4k views

How should I unit test a function that uses setters?

I'm using a repository pattern design and I've hit a stumbling block when writing a unit test for one of my methods. I'm fairly new to writing unit tests, so I would appreciate any help! Let's say I ...
1
vote
2answers
907 views

Test a wrapper to external static/singleton

I am integrating an external library that declares a singleton, like this: public class External : MonoBehaviour { public static External Instance { get {/*setup inner stuff*/} } public void ...
0
votes
2answers
578 views

Should I test the aspects that type checking covers?

For example, should I test like this: // it shouldn't even compile since I'm using a static type-checking expect(addTen('string')).toThrowError() when it is already type-checked like this: function ...
7
votes
1answer
972 views

To what extent should I test what should not happen

In the case of unit testing, I'm testing as many cases as I can that when I do X, Y happens. I'm also concerned in some cases that when I do X, Z does not happen. But for the sake of protection, I ...
3
votes
1answer
176 views

Should I be unit testing “non dynamic” properties? [duplicate]

There is an ongoing debate about the following property, and if it should be tested or not. We're working in C#. MyClass prop => value; Should I be writing the following unit test : IMyClass ...
2
votes
1answer
594 views

When is interaction testing (invocation verification) while unit testing considered excessive?

I am under the impression that interaction testing (verifying mock invocations) in general should be avoided. When unit testing method postconditions should be asserted instead. However there are ...
1
vote
1answer
189 views

Should I cover code that should not be able to fail with tests?

I'm asking myself above question since I implemented an API that accesses a third-party API and currently write tests to increase my code coverage in the class that communicates with the third-party ...
1
vote
1answer
4k views

Is it worth writing a unit test for a DTO with the most basic getter/setters? [duplicate]

The advantage is it protects your DTO against future "enhancements" ?
0
votes
1answer
822 views

Do I need to unit test a generic method with all accepted types?

For a method whose signature looks like this: public T Add<T>(T first, T second) where T : struct, IEquatable<T>, IComparable<T> which can work with all of the integral types, do I ...
0
votes
1answer
208 views

Is this wrapper class too simple to test?

I have a following class in my PHP code: <?php declare(strict_types=1); use function Http\Response\send; use Psr\Http\Message\ResponseInterface; class ResponseSender implements ...
0
votes
1answer
177 views

How to test this getRandom() method? [duplicate]

There are strings and each string has a weight in a data structure. The getRandom() method should return a string randomly with its weight/total weight probability. There is already a question on how ...
4
votes
0answers
161 views

unit testing a mocked class [duplicate]

I'm currently writing unit tests for my PHP code. I've read that unit tests should not interract with external elements such as network and filesystem. In my code i have a curl wrapper class to ...

15 30 50 per page