Nancy.Testing - executable specifications through the full stack, in memory

Nancy Logo

When I showed the code from the last post to a colleague (Hugo Häggmark), he remarked: Nice - but that’s no unit test. And he’s absolutely right.

A unit test should test a unit. The tests in the last post, and the test that Nancy.Testing allows us to easily write, flexes the whole stack of our application. In memory (which is super cool) but the full stack. That’s no unit test.

This can still be VERY useful and in this post I’ll show you how to put one of my favorite tools, SpecFlow, in front of what we wrote in the last post, to get an executable specification. Not only that - I’ll do it in a manner that lets you swap it and hit the HTML page if you wanted to.

As the tradition calls - let’s look in wonder at...

Read More

Nancy.Testing - no hat, no shoes with Simple.Data

This is the fourth (oh my!) post in my series on Nancy.Testing. This time we will leave the Nancy.Testing specific stuff and let our gal meet a friend of mine: Simple.Data(.Testing). By marrying these kids together we will have a really cool full-stack-in-memory-testing-experience (FSIMTE it’s gonna be a thing!).

I’ll supply you with some background to Simple.Data and it’s (awesome) testing capabilities, and I probably have to explain the title of this blog post, but then it’s just code all the way down.

The other posts in the series can be found here:

  1. Intro to testing with Nancy
  2. The Configurable bootstrapper
  3. The Browser and Response objects
  4. Hat and shoeless testing with Simple.Data(this post)
  5. SpecFlow and Nancy

Let’s dive right in a say hello to Simple.Data, if you haven’t met him already.

Simple.Data

Simple.Data is a...

Read More

Nancy.Testing - testing (razor) views

I’m in the middle of writing a blog post series on Nancy.Testing and this bit me a bit (sorry, couldn’t resist myself).

I have written a lot about how to test web-responses and all the great stuff that comes with it, but totally forgot about view. I assumed that it “just worked”. And it does but… well read on. It’s really simple.

Keeping the story short - let’s cut to the code: There’s some really important settings to make here. If you don’t you’ll end up with an (as always in Nancy btw) excellent error message, something like this:

Nancy.ViewEngines.ViewNotFoundException: > Unable to locate view 'FariyTaleFigure' Currently available view engine extensions: sshtml,html,htm,cshtml,vbhtml > > Locations inspected: > views/SimpleDataModuleWithView/FariyTaleFigure-sv-SE,views/SimpleDataModuleWithView/FariyTaleFigure,SimpleDataModuleWithView/FariyTaleFigure-sv-SE,SimpleDataModuleWithView/FariyTaleFigure,views/FariyTaleFigure-sv-SE,views/FariyTaleFigure,FariyTaleFigure-sv-SE,FariyTaleFigure > Root path: C:\Dev\DiscoveringNancyThroughTests\DiscoverNancy.Tests\NancyAndSimpleData.Tests\bin\Debug 

Oh yeah - the two settings you need to do:

  • First install the Razor (or the view engine of choice) NuGet package: Install-Package Nancy.Viewengines.Razor
  • Then set...
Read More

Nancy.Testing - test-dialogues with Requests and Response

Nancy Logo

This is the third post in my series on Nancy.Testing. It will focus a lot on the Browser and the Response object. Together with the Browser (and its ConfigurableBootstrapper), these objects make up the entirety of the Nancy.TestingFramework. Let’s do the logo thing again, shall we?

The other posts can be found here:

  1. Intro to testing with Nancy
  2. The Configurable bootstrapper
  3. The Browser and Response objects (this post)
  4. Hat and shoeless testing with Simple.Data
  5. SpecFlow and Nancy

By now you’re probably just looking for the code so let’s dive right in.

Browser

The Browser object is the one that you use to issue requests to the site you’re testing. Most of the Browser configuration is done through the ConfigurableBootstrapper and let’s not go over that again.

But the Browser has a couple of other tricks up...

Read More

www.marcusoft.net - 800 posts and counting

I’ve just published my 800th post!

Can’t really understand that. I know that some of them haven’t been all that great but there’s some nuggets of information in there. At least for me.

That’s how I started to blog: to make myself write stuff down to remember and formalize my knowledge.

800 posts, six years, 163 000 pageviews. That’s not a lot for many blogs out there but it means a lot to me.

Thank you for reading my blog. Even though I started to write it for myself - comments and reactions is  what kept me going on for 6 years! I cannot promise 6 more but right now I’m on a roll.

Read More

Pickles - Generate SpecFlow Documentation from MSBuild and PowerShell

If you’re doing specification by example or BDD, you will soon realize that the tooling still points towards developers. With that, I mean that Cucumber and SpecFlow allow you to write your executable specifications in plain text, but you still check it into the source repository. This is, of course, a good thing since you’d want to version the specification with your code - but it also effectively hides it and keeps the spec out of reach for any non-developing member of the team.

Make no mistake here: the .feature-file is the master and original. That’s how it should be since it’s versioned together with the code. But we want everyone on the team to be able to read the specifications and see the test result easily. So we generate documentation off the .feature-files.

Pickles is a nice OSS framework that helps you solve this...

Read More

Nancy.Testing - configure her boot...strapper

Nancy Logo

This is the second post in my series on the awesome testability of Nancy - a minimalistic web framework on the .NET / Mono platform. Let’s throw in the logo again - it’s so nice.

The other posts can be found here:

  1. Intro to testing with Nancy
  2. The Configurable bootstrapper (this post)
  3. The Browser and Response objects
  4. Hat and shoeless testing with Simple.Data
  5. SpecFlow and Nancy

This post covers a basic feature that makes up much of the awesomeness that is around configurability in Nancy testing: the configurable bootstrapper.

There’s a wiki-post on testing on the Nancy Github wiki but it leaves the ConfigurableBootstrapper with a mere mentioning. I think it deserves a deeper look, since through this, you can actually control and swap out most anything from the Nancy framework. Even ViewEngines and the NancyEngine...

Read More

Nancy.Testing - A Closer Look Through Her Testability

Nancy Logo

For quite some time, I’ve been a fan and proponent of a .NET web framework called Nancy. She describes herself as a “a lightweight, low-ceremony, framework for building HTTP based services on .Net and Mono,” and she looks like the picture on the side.

There’s much to admire about Nancy (a working web app in a tweet is really cool) and the code and features are pure quality from start to finish, much to the work that @theCodeJunkie (Andreas Håkansson) and Grumpy Dev (Steven Robbins) is putting in, with the help of a growing and engaged community.

The thing that really blew me away when I first saw it was the testing abilities of Nancy. She’s built for testing from the word Go, and that gives us some nice features to play with.

I thought I’d devote a couple of posts to...

Read More

How to run a LeanCoffee discussion

On a Sunday night a got a mail that asked me to do a presentation tomorrow. New client. Want to put best foot forward. :) So I threw one together and here’s the run down of it. Thinking of recording it and put it up somewhere too.

Lean Coffee is a way to hold meetings and gathering that allows for free discussions while still keeping some structure to it. It resembles Open Space Technology but is much easier to set up and run, and often run in small groups. Even though the concept is called Lean Coffee is suitable for discussing most any subject and topics.

Lean Coffee started in Seattle in 2009. Jim Benson and Jeremy Lightsmith first Lean Coffee group has inspired a lot of others around the globe. I’ve taken part in the one in Stockholm LeanKaffeSump quite a few times, but have also run...

Read More

Team Marketplace - How We Split a Big 40-Person Team into 5 Small in 2 Hours

I have a new coaching assignment at Tradera, which is the Swedish branch of Ebay. I’ve been there about 30 hours during the last three years, mostly doing presentations and courses. In a way it feels like I’ve been part of what they have done, but only as a bystander. This gig looks like a lot of fun, and I’ve always been impressed by the technical excellence there and the willingness to adopt new things and change.

I was thrown right in at the deep end as they were about to reorganize their big team (30-40 people) into 5 smaller teams with particular features to look after. The first thing they wanted help with was some input around HOW to go about organizing this. And make no mistake - they were well on their way doing this in an excellent way already. I merely supplied some confirmation and...

Read More