2011-05-17 73 views
2

在specflow中,如果您創建了一個名稱爲「Do something usefull」的方案,則生成的單元測試將被命名爲「DoSomethingUsefull」(不含空格)。如果你有很長的場景名稱,這在nunit測試運行器中不是非常可靠的。Specflow:在單詞之間生成帶下劃線的測試

有沒有辦法用下劃線分隔單詞? (?像設置)

回答

3

的唯一方法是現在修改SpecFlow的源代碼


namespace TechTalk.SpecFlow 
{ 
    public static string ToIdentifierPart(this string text) 
    { 
     text = firstWordCharRe.Replace(text, match => match.Groups["pre"].Value + match.Groups["fc"].Value.ToUpper()); 

     // --- add this line --- 
     text = text.Replace(" ", "_"); 

     text = punctCharRe.Replace(text, "_"); 
     text = RemoveAccentChars(text); 

     if (text.Length > 0) 
      text = text.Substring(0, 1).ToUpper() + text.Substring(1); 

     return text; 
    } 
} 
+1

真實的 - 但在OSS合作精神;前往https://github.com/techtalk/SpecFlow併爲此創建一個問題。我認爲這會很好 - 尤其是在設置切換 – 2011-05-18 05:24:16

+0

完成!好建議! – Julien 2011-05-18 08:18:24

相關問題