Sign in
Being Cellfish
Stuff I wished I've found in some blog (and sometimes did)
Translate This Page
Translate this page
Powered by
Microsoft® Translator
Tags
*nix
.Net
Agile
Azure
BDD
C++
Christmas
DDD
Development
GUI
Java
Kanban
MFC
Military
Open source
Pages
PHP
Python
Relocate
Review
Robot
Ruby
SCX
Security
SQL
TDD
Test
Tools
Browse by Tags
MSDN Blogs
>
Being Cellfish
>
All Tags
>
test
Tagged Content List
Blog Post:
If it is hard to test, you did something wrong
Emil Gustafsson
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...
on
16 May 2013
Blog Post:
TestInitialize execution order
Emil Gustafsson
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...
on
14 Jan 2013
Blog Post:
Listening to port 80 without being admin
Emil Gustafsson
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...
on
19 Jul 2012
Blog Post:
Stress testing with Fiddler
Emil Gustafsson
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...
on
16 Jul 2012
Blog Post:
Evolution of a hand rolled fake - part 4
Emil Gustafsson
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...
on
9 Jul 2012
Blog Post:
Evolution of a hand rolled fake - part 3
Emil Gustafsson
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...
on
5 Jul 2012
Blog Post:
Evolution of a hand rolled fake - part 2B
Emil Gustafsson
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...
on
2 Jul 2012
Blog Post:
Evolution of a hand rolled fake - part 2
Emil Gustafsson
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...
on
29 Jun 2012
Blog Post:
Evolution of a hand rolled fake
Emil Gustafsson
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...
on
16 Jan 2012
Blog Post:
Assert.Inconclusive
Emil Gustafsson
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...
on
22 Jan 2011
Blog Post:
Sometimes you need to be careful how you setup your tests
Emil Gustafsson
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...
on
11 Jul 2010
Blog Post:
MSTest does not call all tests in a class before moving on the the next test class
Emil Gustafsson
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...
on
15 Jun 2010
Blog Post:
Pex and Moles
Emil Gustafsson
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...
on
27 May 2010
Blog Post:
Getting code coverage in visual studio 2010 when using xUnit.net
Emil Gustafsson
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...
on
22 May 2010
Blog Post:
Using C# properties to create a domain specific language
Emil Gustafsson
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:...
on
10 Feb 2010
Blog Post:
Test readability
Emil Gustafsson
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...
on
12 Jun 2009
Blog Post:
When to write passing tests before fixing a bug
Emil Gustafsson
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...
on
21 Apr 2009
Blog Post:
CAT - Continuous Acceptance Testing
Emil Gustafsson
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...
on
17 Jan 2009
Blog Post:
Why slow unit tests are a bad smell:
Emil Gustafsson
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...
on
7 Jan 2009
Blog Post:
CUT - Continuous Unit Testing
Emil Gustafsson
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...
on
5 Jan 2009
Blog Post:
Yet another reason for loving xUnit.net
Emil Gustafsson
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...
on
26 Nov 2008
Blog Post:
Dangers of using Visual Studio 2008 Team System Code Coverage Tool for Native C++
Emil Gustafsson
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...
on
18 Nov 2008
Blog Post:
Native C++ Code Coverage reports using Visual Studio 2008 Team System
Emil Gustafsson
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...
on
16 Nov 2008
Blog Post:
Exit Mocks. Enter Stubs!
Emil Gustafsson
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...
on
14 Oct 2008
Blog Post:
My new favorite .Net unit test framework
Emil Gustafsson
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...
on
24 Sep 2008
Page 1 of 2 (31 items)
1
2