Convert C# unit test names to English (testdox style)

橙三吉。 提交于 2019-12-04 15:42:22

There is a TestDox for .NET It seems fairly recent (2010).

For a presentation last year I have created a small BDD unit testing helper that displays the method names being executed in normal English. The string magic part of it is quite thin so you can surely extract it from it.

Here is my post with the link to the download: http://gasparnagy.blogspot.com/2009/10/devcamp09-behavior-driven-development.html

Have a look at developwithpassion.bdd and bdddoc, developed by JP Boodhoo.

His original blog post on it is here: http://blog.jpboodhoo.com/BDDDoc.aspx

You can find the code on github here: http://github.com/developwithpassion/developwithpassion.bdd

I use his testing framework, and BDDDoc generates plain English HTML reports that even show whether the tests pass or not, by tying into the mbUnit and Gallio reports.

The format, though is that each fixture has a Concern attribute for bdddoc to pick up and group the specs.

My fixtures are named like public class When_the_sound_system_is_off... and my assertions are delegates of type it (from the framework), so they read it should_not_be_spinning_a_compact_disc..., it should_emit_no_sound..., etc.

BDDDoc works off this underscorish syntax, but I think since you are already using mbUnit, you can probably extract the interesting bits of code and tailor it to your needs.

StoryQ has quite a good workflow for converting existing unit tests to BDD style - I know that's not directly answering your question but might be worth checking out...

This C# test framework also does a very good job of converting method to English

UBADDAS - User Behaviour and Domain Driven Acceptance Stories

found here - http://kernowcode.github.io/UBADDAS/

Converts this ...

[Test]
public void IWantToRegisterANewUser()
{
  ICustomer customer = new Customer();

  SoThat(MyBusinessValue.IncreaseCustomerBase)
    .As(new User())
    .Given(customer.Register)
    .When(customer.Confirm_Registration)
    .Then(customer.Login);
}

to this ...

I want to register a new user
  So that Increase customer base
       As user
    Given Register customer
     When Confirm customer registration
     Then Login customer
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!