Tag Archives: TDD

Test-Driven Development: By Example

Book cover

I earlier wrote about the book, The Art of Unit Testing, which I finished a while ago. That book was very good and was focused on how to write good unit tests. It also mentioned Test-Driven Development, TDD, but not too much. The book I read next, which I finished a few days ago, was kind of the other way around. Pretty much only about TDD. And from the title, Test-Driven Development: By Example, that shouldn’t be much of a shocker :P

Continue reading

C#: How to test asynchronous events

The other day I had to test that an event was raised after some asynchronous work had been done. And since I currently am a total test newbie, this was a new thing for me. Say we have this simple shell of a class:

public class Worker
{
    public event EventHandler<eventargs> Done;

    public void Start()
    {
       ...
    }
}</eventargs>

Let’s just assume it does some work, and is supposed to raise the Done event when it is… well… done.

Continue reading

The Art of Unit Testing

The Art of Unit Testing (Book cover)Have you gone through three years of computer science bachelor degree fun (or anything similar) and pretty much not heard a word about testing? Or have you heard from all your teachers that testing is extremely important, but never learned how to even write one? That has been the case for me. Testing is important, you all got to do it, it is very important, always test, do it a lot! Well, sure… but how do I do it? How do I write one of these tests?

Continue reading

Project Euler: Just two tiny notes

Just two things I felt like mentioning:

Thing number one

I got tired of the page 2 stuff. So, I swapped all the <!–nextpage–> things with <!–more–> and a header. Which means that the solution will now be on the same page as the problem. (Although not on the index page).

Thing number two

My brother puts his whole solution on a public subversion repository, which is a very good idea. Following his good example, I did a repository dump of my local VisualSVN Server and… undumped(??) it into one I set up here on my web host which I will be using from now on instead.

Update: SubVersion turned out to be a bit blah sometimes, so I am trying out Mercurial now instead. The repository has been converted and published on BitBucket. Mercurial seems a lot nicer than SubVersion so far. You can find a very good introduction at hginit.com.

Thing number three

Works On My MachineOk, ok, the topic says two, but I just figured I should maybe mention one more thing. You see, the code you will find in my aforementioned subversion repository cannot be run. Like, there is no main method or anything there. That is because I am trying to teach myself how to use test cases, etc. So, instead of creating an executable program for each problem or one program with fancy “Solve problem #n”-buttons, I decided to just do it all in test cases. So, my solutions are actually found as part of the test project (well, the running of them anyways). I am using TestDriven.net to run them, and it works great. This way I can also do a lot of changes, and then just run my tests and make sure that all my solutions still calculate correctly. Awesome stuff.