Tôi có khách sạn này:Tôi có thể định cấu hình NUnit để Debug.Fail không hiển thị hộp thông báo khi tôi chạy thử nghiệm của mình không?
public SubjectStatus Status
{
get { return status; }
set
{
if (Enum.IsDefined(typeof(SubjectStatus), value))
{
status = value;
}
else
{
Debug.Fail("Error setting Subject.Status", "There is no SubjectStatus enum constant defined for that value.");
return;
}
}
}
và kiểm tra đơn vị này
[Test]
public void StatusProperty_StatusAssignedValueWithoutEnumDefinition_StatusUnchanged()
{
Subject subject = new TestSubjectImp("1");
// assigned by casting from an int to a defined value
subject.Status = (SubjectStatus)2;
Assert.AreEqual(SubjectStatus.Completed, subject.Status);
// assigned by casting from an int to an undefined value
subject.Status = (SubjectStatus)100;
// no change to previous value
Assert.AreEqual(SubjectStatus.Completed, subject.Status);
}
Có cách nào tôi có thể ngăn chặn Debug.Fail hiển thị một hộp thông báo khi tôi chạy thử nghiệm của tôi, nhưng cho phép nó để hiển thị tôi khi tôi gỡ lỗi ứng dụng của mình?
Tôi đã cập nhật câu trả lời của mình để chứa trình theo dõi trình lắng nghe theo dõi cho NUnit, nếu bạn quan tâm. –
Tuyệt vời, chỉ là loại thông tin tôi đang tìm kiếm! – Grokodile