Linked Questions

-1 votes
1 answer
171 views

Are simple lambdas testable? [duplicate]

I have a simple lambda that is basically x => "Error: "+x+".". I was just wondering if this was worth a test. It's really just a one-liner, so there's not much that can go wrong....
DaCool1's user avatar
  • 37
4 votes
1 answer
228 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 ...
Gil Sand's user avatar
  • 2,173
4 votes
0 answers
181 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 ...
ᴄʀᴏᴢᴇᴛ's user avatar
0 votes
0 answers
78 views

Unit test coverage and abundant glue code [duplicate]

How do I solve this riddle of contradicting "good practices" to properly cover my app with unit-tests? These are principles I found about writing unit-tests: Pyramid of testing says unit-...
Gherman's user avatar
  • 945
0 votes
0 answers
48 views

How do you decide what is worth writing a unit test for [duplicate]

In an app I'm working in there's a service class(among others) which is used just to call methods on other classes. Recently I've had to work in that area and add another method that does what all the ...
Andrei's user avatar
  • 109
79 votes
10 answers
37k 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 ...
Zenzen's user avatar
  • 996
53 votes
10 answers
7k views

How should I test "Glue Functions" without testing that "the code I wrote is the code I wrote"?

I usually write my code in a test driven style. I write tests as specifications and then my code. It's great and useful. I always try to ignore implementation when testing and only test behaviour. I ...
Derek C.'s user avatar
  • 617
21 votes
9 answers
80k 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 ...
IS1_SO's user avatar
  • 347
25 votes
3 answers
17k 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 ...
frostings's user avatar
  • 660
12 votes
5 answers
15k 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 ...
Onorio Catenacci's user avatar
18 votes
2 answers
5k 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 ...
Daniel Kaplan's user avatar
5 votes
3 answers
2k 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 = ...
DFENS's user avatar
  • 375
-1 votes
5 answers
3k 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 ...
Bob Horn's user avatar
  • 2,337
2 votes
2 answers
6k 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 ...
Dan Johnson's user avatar
2 votes
3 answers
1k 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 ...
Adelin's user avatar
  • 281

15 30 50 per page