How to measure test coverage in Go

Note that Go 1.2 (Q4 2013, rc1 is available) will now display test coverage results: One major new feature of go test is that it can now compute and, with help from a new, separately installed “go tool cover” program, display test coverage results. The cover tool is part of the go.tools subrepository. It can be installed by running The cover tool does two things. … Read more

What’s the difference between a mock & stub?

Stub I believe the biggest distinction is that a stub you have already written with predetermined behavior. So you would have a class that implements the dependency (abstract class or interface most likely) you are faking for testing purposes and the methods would just be stubbed out with set responses. They would not do anything … Read more

How can I time a code segment for testing performance with Pythons timeit?

You can use time.time() or time.clock() before and after the block you want to time. This method is not as exact as timeit (it does not average several runs) but it is straightforward. time.time() (in Windows and Linux) and time.clock() (in Linux) are not precise enough for fast functions (you get total = 0). In this case or if you want to average the … Read more

How can I solve the error LNK2019: unresolved external symbol – function?

One option would be to include function.cpp in your UnitTest1 project, but that may not be the most ideal solution structure. The short answer to your problem is that when building your UnitTest1 project, the compiler and linker have no idea that function.cpp exists, and also have nothing to link that contains a definition of multiple. A way to fix this is making use … Read more

What is a sanity test/check

A sanity test isn’t limited in any way to the context of programming or software engineering. A sanity test is just a casual term to mean that you’re testing/confirming/validating something that should follow very clear and simple logic. It’s asking someone else to confirm that you are not insane and that what seems to make … Read more