3
votes
4answers
179 views

How to identify and run the most relevant automated tests?

Suppose you have a reasonably large codebase (0.5 - 1 msloc) with a large test-suite (6-7hr single-threaded runtime; with a mix of unit-tests and integration-tests built with different tools). You ...
0
votes
1answer
179 views

Is testability and mockability really that important in web development?

I'm reading this series on Laravel, and it's in great depth dealing with making everything testable, using Repository instead of just using the Models, using Dependency Injection and other obscure ...
1
vote
3answers
329 views

Does non-virtual-by-default lead us to composition-over-inheritance?

There are some design guidelines about testable code in “The Art of Unit Testing”. The first one is “Make methods virtual by default”. I’m curious to know your idea about non-virtual-by-default ...
15
votes
5answers
883 views

Is this pattern bad? [duplicate]

I notice that when I code I often use a pattern that calls a class method and that method will call a number of private functions in the same class to do the work. The private functions do one thing ...
2
votes
2answers
189 views

Should I split out synchronization from my class and what's it called?

When thinking about testability and modular code, I recently thought about whether I should split out the synchronization part of a class from the actual behavior part. By example: The app "needs" ...
11
votes
3answers
569 views

Is using unit tests to tell a story a good idea?

So, I have an authentication module I wrote some time ago. Now I'm seeing the errors of my way and writing unit tests for it. While writing unit tests, I have a hard time coming up with good names and ...
3
votes
3answers
644 views

iOS - Unit tests for KVO/delegate codes

I am going to design a MVC pattern. It could be either designed as a delegate pattern, or a Key-Value-Observing(KVO), to notify the controller about changing models. The project requires certain ...
9
votes
4answers
793 views

How to unit test a function that is refactored to strategy pattern?

If I have a function in my code that goes like: class Employee{ public string calculateTax(string name, int salary) { switch (name) { case "Chris": ...
3
votes
4answers
672 views

When, Where, and How to Unit Test [duplicate]

I'm very familiar with xUnit frameworks and I try to implement unit tests on every project I start. Somewhere along the way, I realize that I'm writing the same tests over and over again, and then I ...
6
votes
6answers
1k views

Can the Strategy pattern be implemented without significant branching?

The Strategy pattern works well to avoid huge if...else constructs and make it easier to add or replace functionality. However, it still leaves one flaw in my opinion. It seems like in every ...
28
votes
7answers
5k views

Is dependency injection essential for unit testing?

Is using dependency injection (DI) essential for unit testing? I can't think of another alternative for isolating code so it can be tested. Also, all the examples I have ever seen use this pattern. ...
0
votes
1answer
3k views

Implementing a ILogger interface to log data

I have a need to write data to file in one of my classes. Obviously I will pass an interface into my class to decouple it. I was thinking this interface will be used for testing and also in other ...
5
votes
4answers
272 views

Type mocking frameworks does not change coding practices from testability point?

Many people recommend that we should code against interfaces and avoid statics for testability. Interfaces are not just for testability, they are sometimes a requirement. But sometimes we introduce ...
18
votes
5answers
9k views

What's the best way to build a factory using NInject?

I am pretty comfortable with dependency injection using NInject in MVC3. While working in an MVC3 application, I developed a custom Controller Creation Factory using NInject, so any controller that is ...
9
votes
2answers
1k views

design pattern for unit testing? [duplicate]

I am beginner in developing test cases, and want to follow good patterns for developing test cases rather than following some person or company's specific ideas. Some people don't make test cases and ...