2

Imagine that we have 1000 functions in our program. Do we need to test all of them?

Can we give some priorities to the functions and can we test some of them after that but not all?

To do this which tools and metrics can we use?

1

3 Answers 3

2

It's best to test everything that isn't obviously ok, skipping just trivial things like getters and setters.

But you might want to measure cyclomatic complexity and worry more about the more complex functions.

2

Do we need to test all of them?

No. To start with it would be worth following the bugs. Every new bug should end with at least one unit test demonstrating it. Ideally however you would want to retrofit a reasonable automated test suite. Crap4J and Clover can give you an idea on where to start. Clover has its Project Risks and Quick Wins clouds (basically views on cyclomatic complexity and test coverage) which will give some guidance on what should be testing and what will help keep the moral up.

1

In an ideal world, you will have multiple Unit Tests for each method (or function) in your solution. In reality, this usually doesn't happen, especially when working on existing systems.

There are no automated ways to prioritize which methods you should unit test since every software solution is different. I would focus on methods and classes that are the core of your solution, and try to get as much unit test coverage on those methods. Then focus on the other parts of your code.

Unit testing tools vary based on your language and environment. Visual Studio includes basic unit testing, additionally there is NUnit for .NET testing. For Java there is JUnit.

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.