Unit testing is a method by which individual units of source code are tested to determine if they are fit for use.
A unit is the smallest testable part of an application. In procedural programming, a unit may be an individual function or procedure. Unit tests are created by programmers or occasionally by white box testers.
In some organisations, apparently, part of the software release process is to use unit testing, but at any point in time all unit tests must pass. Eg there might be some screen which shows all unit tests passing in green - which is supposed to be…
A bit of context: Earlier today I had to update some SQL code that another colleague of mine provided, and since it’s a pretty large script, it’s stored as a separate file (which is then read and executed at runtime). While doing this I accidentally…
I read about this snafu: Programming bug costs Citigroup $7m after legit transactions mistaken for test data for 15 years.
When the system was introduced in the mid-1990s, the program code filtered out any transactions that were given three-digit…
In my unit tests, I often throw arbitrary values at my code to see what it does. For example, if I know that foo(1, 2, 3) is supposed to return 17, I might write this:
assertEqual(foo(1, 2, 3), 17)
These numbers are purely arbitrary and have no…
Triggered by this thread, I (again) am thinking about finally using unit tests in my projects. A few posters there say something like "Tests are cool, if they are good tests". My question now: What are "good" tests?
In my applications, the main part…
I've been going through phpunit's docs and came accross the following quote:
You can always write more tests. However, you will quickly find that only a fraction of the tests you can imagine are actually useful. What you want is to write tests that…
I started writing some unit tests for my current project. I don't really have experience with it though. I first want to completely "get it", so I am currently using neither my IoC framework nor a mocking library.
I was wondering if there is…
Most unit testing tutorials/examples out there usually involve defining the data to be tested for each individual test. I guess this is part of the "everything should be tested in isolation" theory.
However I've found that when dealing with…
I have a chunk of code that looks something like this:
function bool PassesBusinessRules()
{
bool meetsBusinessRules = false;
if (PassesBusinessRule1
&& PassesBusinessRule2
&& PassesBusinessRule3)
{
…
Obviously some old applications can't be or is extremely difficult to unit test because of the way it was written in the first place.
But in places, like some helper methods which could probably be unit tested, should I bother writing unit tests for…
Imagine a simple AngularJS REST Service which retrieves (GET) data from REST endpoints on a server. It maintains no state of its own and each method only passes back a promise to whomever is using said service.
Now, should I write tests for this…
I work at a place where we buy a lot of IT projects. We are currently producing a standard for systems-requirements for the requisition of future projects. In that process, we are discussing whether or not we can demand automated unit testing from…
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 controller returned the wanted type by executing the…
I'm a member of my high school's robotics club, and am responsible for programming the robot. One suggestion I keep hearing from various adults is that I should be writing unit tests to help validate my code. The code base is getting a bit big,…
I had a discussion with a testing manager about the role of unit and integration testing. She requested that developers report what they have unit and integration tested and how. My perspective is that unit and integration testing are part of the…