2010-03-12 41 views
2

我有一大堆用MbUnit編寫的單元測試,我想從測試名稱生成純英文句子。這一概念在這裏介紹:將C#單元測試名稱轉換爲英語(testdox風格)

http://dannorth.net/introducing-bdd

這是從文章:

public class CustomerLookupTest extends TestCase { 
    testFindsCustomerById() { 
     ... 
    } 
    testFailsForDuplicateCustomers() { 
     ... 
    } 
    ... 
} 

呈現這樣的事情:

 
CustomerLookup 
- finds customer by id 
- fails for duplicate customers 
- ... 

不幸的是,上述文章中所引用的工具(testdox )是基於Java的。有沒有一個.NET?

這樣的聲音會寫得很簡單,但我根本沒有帶寬,並且想使用已寫入的內容。

編輯:只是爲了澄清問題。我正在尋找能夠通過現有測試並將CamelCase函數名稱轉換爲句子的東西。似乎是某種Gallio插件的完美工作。

到目前爲止,我不知何故發現SpecUnit和傑伊建議BDDDoc。這兩個都是行爲驗證框架,需要對現有測試進行重大改寫。我們的團隊做出了將SpecFlow作爲主要BDD框架的決定,我試圖實現的目標是生成一份現有測試報告,以查看它是否適合BDD方法。

回答

2

有一個TestDox for .NET 似乎相當近期(2010年)。

+0

Aha,正是我一直在尋找的東西。 –

1

查看JP Boodhoo開發的developwithpassion.bddbdddoc

上他原來的博客文章是在這裏:http://blog.jpboodhoo.com/BDDDoc.aspx

您可以在這裏找到在GitHub代碼:http://github.com/developwithpassion/developwithpassion.bdd

我用自己的測試框架,並BDDDoc產生純英文的HTML報告,甚至顯示是否測試通過與否,通過綁定到mbUnit和Gallio報告。

該格式雖然是每個燈具都有Concern屬性供bdddoc拾取和分組規格。

我的燈具被命名爲喜歡public class When_the_sound_system_is_off...,我的主張是it類型(根據框架)的代表,所以他們讀it should_not_be_spinning_a_compact_disc...it should_emit_no_sound...

BDDDoc工作過這個underscorish語法,但我想既然你是已經使用mbUnit,你可能會提取一些有趣的代碼,並根據你的需要進行調整。

2

去年介紹我創建了一個小的BDD單元測試幫手顯示器方法名稱以正常英語執行。它的字符串魔法部分非常薄,所以你可以肯定地從中提取它。

這裏是我的職位與鏈接到下載:http://gasparnagy.blogspot.com/2009/10/devcamp09-behavior-driven-development.html

+0

當使用代碼的「字符串魔法」部分時,是否有任何許可證遵守?這真的很棒,我想在我的單元測試depascalization中使用它,但我不想侵犯任何版權等。 –

0

這個C#的測試框架也做轉換方法,以英語

UBADDAS的一個很好的工作 - 用戶行爲和領域驅動驗收故事

這裏找到 - http://kernowcode.github.io/UBADDAS/

將這個...

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

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

對此...

I want to register a new user 
    So that Increase customer base 
     As user 
    Given Register customer 
    When Confirm customer registration 
    Then Login customer