Being Cellfish

Stuff I wished I've found in some blog (and sometimes did)

Browse by Tags

Tagged Content List
  • Blog Post: If it is hard to test, you did something wrong

    I've often been asked questions like how would you test this or been told that there cannot be unit test for some code because it is impossible to test. Well, my opinion is that if something is hard to test it is all your fault. You designed it, you implemented it and hence it is your fault it is hard...
  • Blog Post: TestInitialize execution order

    This was brought to my attention and I was blown away by the fact that somebody would mark classes as TestClass without any tests in them just to reuse some setup code. And that they then make any assumptions on in which order the methods are called. If you really want to do that the constructor is a...
  • Blog Post: Listening to port 80 without being admin

    If you're writing integration or so called end-to-end tests for web services you typically need to spin up a service locally just for a few tests. Or maybe you're just interested in doing some manual testing locally. In both cased you likely need to be an administrator to be able to listen to the desired...
  • Blog Post: Stress testing with Fiddler

    If you're developing REST based services, Fiddler should not be news to you. But there might be a little trick you can use to do some simple stress testing. If you select one or more sessions in the Web Sessions pane and then hit shift+R you get a little dialog asking for number of times to replay the...
  • Blog Post: Evolution of a hand rolled fake - part 4

    Another hard problem when it comes to creating fakes is when the interface contain overloads (i.e. same method name but different parameters) like this: 1: public interface IYetAnotherInterface 2: { 3: int DoSomething(); 4: int DoSomething( int x); 5: } The Fakes utility in VS11 will generate...
  • Blog Post: Evolution of a hand rolled fake - part 3

    So how do I fake an interface with properties? 1: interface IAnotherInterface 2: { 3: int SomeProperty { get ; } 4: int SomeOtherProperty { get ; set ; } 5: } Most of the time I just let my fake have the property implemented. This works most of the time but only really well if the interface...
  • Blog Post: Evolution of a hand rolled fake - part 2B

    While the last version I showed is very flexible I have experimented a little more. Why would you ever have a public getter on the fake handler properties? Maybe if you had a fake that needed to wrap existing fake behavior but this is probably pretty rare. So this is what it would look like with no public...
  • Blog Post: Evolution of a hand rolled fake - part 2

    In a recent discussion at work I realized that the main reason I started with the constructor based fakes descried here was not to clutter the object with properties called Something Handler . By having my fake implement the interface explicitly I could create a fake like this: 1: public class FakeTheInterface...
  • Blog Post: Evolution of a hand rolled fake

    I usually hand roll my own fake objects for my tests. They have always looked a lot like what Stubs generate. I just think that it's so cheap to create them that I don't even need Stubs. In this series I'll assume an interface that looks like this: 1: interface ITheInterface 2: { 3: void DoSomething...
  • Blog Post: Assert.Inconclusive

    I'm currently using MSTest in my day to day work and I'm not always writing true unit tests but occasionally I'm also writing what I call integration tests. That is tests that uses a real database and/or web service. As such these integration tests are fragile and might fail because of the configuration...
  • Blog Post: Sometimes you need to be careful how you setup your tests

    I've been working with MSTest (the unit test framework that comes with Visual Studio) lately and I learned the hard way that it is a bad idea to not use the TestInitialize attribute. This may sound obvious to you but I'm more used to work in xUnit.net and there I typically setup as much as I can with...
  • Blog Post: MSTest does not call all tests in a class before moving on the the next test class

    I recently heard of somebody who moved away from using MSTest and started to use NUnit because NUnit called the class setup method, then all tests and last the class tear-down before moving on to the next test class while MSTest more or less interleaved everything. I'm not a big fan of MSTest so I'm...
  • Blog Post: Pex and Moles

    Yesterday I attended a class about Pex and Moles held by the authors of named tool(s). The first part was about Moles which is kind of like Stubs ( which I've covered before ) but more powerful. With Moles you can fake any method in any class. I'll say that again. Any method in any class . That is very...
  • Blog Post: Getting code coverage in visual studio 2010 when using xUnit.net

    Recently I set up a project where i wanted to use xUnit.net as a unit test framework and I also wanted code coverage so I thought it should be easy using VS2010. Even though the final solution turned out to be fairly simple there were a few bumps on the road. basically I had to do a variant of what I...
  • Blog Post: Using C# properties to create a domain specific language

    So this is nothing new really. People have been creating DSL s using methods and properties for quite some while now I think. But I recently used it to make my fakes (in the unit tests) easier to understand. And I think it turned out pretty neat. Here is an example of what a fake could look like: 1:...
  • Blog Post: Test readability

    I read this excellent post on test readability a few days ago. I like the way he shows how he refactors a test for readability but personally I would have written the example test a little bit differently. First of all I would have added another extension method: 1: public static void PushOkButtonMultipleTimes...
  • Blog Post: When to write passing tests before fixing a bug

    If you're a BDD/TDD practitioner you're probably used to create a failing test whenever you have a new bug reported and you want to fix it. But sometimes a situation arises where you have to do the opposite; creating a passing test before you fix a bug. Let me explain with an example. Let's say that...
  • Blog Post: CAT - Continuous Acceptance Testing

    A few days ago I wrote about Continuous Unit Testing (CUT) and why the need for CUT was a sign of other problems . The last days I have been thinking about CUT a little bit more and I still find CUT questionable but there is another thing - CAT (Continuous Acceptance Testing) that I find very useful...
  • Blog Post: Why slow unit tests are a bad smell:

    Earlier I promised to elaborate on why slow unit tests are a sign of problems (or a smell if you like). So here it goes. The first thing I would like to look at is when the complete test suite takes too long to run to be part of a tight TDD-loop. If it is just the number of tests that makes the difference...
  • Blog Post: CUT - Continuous Unit Testing

    During the Christmas holidays I read about something I would like to call CUT (Continuous Unit Testing). CUT is a technique where you run your unit tests in the background all the time rather than after each time you compile (I'm assuming TDD/BDD is being used all the time). There are a number of reasons...
  • Blog Post: Yet another reason for loving xUnit.net

    I recently noticed a thing about xUnit.net that makes me love that framework even more than before . As you probably already know, an important aspect of (unit) tests is that they can be executed in any order. xUnit.net helps you remember this since it always runs your tests in random order. So simple...
  • Blog Post: Dangers of using Visual Studio 2008 Team System Code Coverage Tool for Native C++

    So now you know how to get coverage reports for native C++ using Visual Studio 2008 Team System (if not - read this ). There are a few things you need to know before you get excited. First of all the only metrics you get are line and block coverage. A block is basically a statement and each line typically...
  • Blog Post: Native C++ Code Coverage reports using Visual Studio 2008 Team System

    The code coverage tool in Visual Studio 2008 Team System is quite easy to use from within the IDE unless you want code coverage for your native C++ code. In order to generate a code coverage report for native C++ you have to use the command line tools. This is how you do it: First of all your project...
  • Blog Post: Exit Mocks. Enter Stubs!

    Since I'm not a fan of mocks I guess my prayers have been heard. Microsoft Research will soon release a stub framework . That's right. Stubs and not mocks! It is part of Pex that I have mentioned before . And you don't need to use Pex if you don't want. You can just use the stub framework by it self...
  • Blog Post: My new favorite .Net unit test framework

    I recently had a chance to really sink my teeth into xUnit.net . Since I've been stuck with CPPUnit for quite some time and working with xUnit.net was a relief. Compared to NUnit I find xUnit much easier and convenient to work with (and compared with CPPUnit it's in a class of it own). I feel I must...
Page 1 of 2 (31 items) 12