我们正在努力使我们的单元测试代码覆盖率尽可能接近 100%。我们做得相当好,但是由于本地化字符串(旨在优雅地失败),结果看起来比实际情况要糟糕得多。
这是我的模型中未涵盖的代码示例:
#region strings
public string AllStr { get { return Localizer.GetString("Resources.Order.Status", "all", "all"); } }
public string ArchivedStr { get { return Localizer.GetString("Resources.Order.Status", "archived", "archived"); } }
public string Closed30Str { get { return Localizer.GetString("Resources.Order.Status", "closed30", "closed30"); } }
public string Closed90Str { get { return Localizer.GetString("Resources.Order.Status", "closed90", "closed90"); } }
public string GoStr { get { return Localizer.GetString("Resources.Global", "go", "go"); } }
public string OpenStr { get { return Localizer.GetString("Resources.Order.Status", "open", "open"); } }
public string OrderStatusStr { get { return Localizer.GetString("Resources.Order.Status", "orderStatus", "orderStatus"); } }
public string SelectedCustStr { get { return Localizer.GetString("Resources.Order.Status", "selectedCust", "selectedCust"); } }
public string StartTypingStr { get { return Localizer.GetString("Resources.Order.Status", "startTyping", "startTyping"); } }
public string TitleStr { get { return Localizer.GetString("Resources.Order.Status", "title", "title"); } }
#endregion
我真的不想将应用程序中的数百个字符串添加到单元测试中,但我也不希望它们影响覆盖结果。
如何从代码覆盖率分析中排除这些字符串,以便更准确地了解重要的测试?