Linked Questions

3
votes
1answer
172 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 ...
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 ...
70
votes
10answers
24k views

Should we test all our methods?

So today I had a talk with my teammate about unit testing. The whole thing started when he asked me "hey, where are the tests for that class, I see only one?". The whole class was a manager (or a ...
17
votes
9answers
45k views

Should one test the values of an enum using unit tests?

If you have an enum with values only (no methods as one could do in Java), and this enum is part of the business definition of the system, should one write unit tests for it? I was thinking that they ...
26
votes
3answers
13k views

Why would you write unit-tests for controllers?

To me this is a totally irrelevant unit-test and I don't understand why someone would spent time writing it, since there is very little value to gain from it. I would know perfectly well if this ...
8
votes
4answers
2k views

How Should I Unit Test A Data Transfer Object?

Consider the following sample C# Data Transfer Object (DTO): public class MailingAddress { public string StreetAddress {get; set;} public string City {get; set;} public string ...
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 ...
-1
votes
5answers
2k views

Is it good practice to have a unit test for a simple data method?

I have a simple data method that does this: public void Write(Foo foo) { db.Foos.Add(foo); db.SaveChanges(); } I was asked to write unit tests for this. To do so, I had to create a fake ...
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 ...
4
votes
3answers
556 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 ...
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" ?
7
votes
1answer
946 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 ...
1
vote
4answers
494 views

Little value in unit-testing the database component

Having a component that represents the database is wonderful! You can use it from the business logic to read and write data. But should that component be unit-tested? I would argue that it should ...
0
votes
2answers
559 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 ...

15 30 50 per page