NUnit / TestDriven.NET risultati contrastanti
-
02-10-2019 - |
Domanda
Quando ho eseguito questo test in NUnit = Red Bar.
[Test]
public void ChangingValueViaPropertyDescriptorRaisesPropertyChangedNotification()
{
PropertyChangedEventArgs pCEventArgs = null;
subjectVM.PropertyChanged += (sender, e) => { pCEventArgs = e; };
PropertyDescriptor descriptor = subjectVM.GetProperties().Find(schoolMeta.Name, false);
descriptor.SetValue(null, "School's out for summer.");
Assert.IsNotNull(pCEventArgs);
Assert.AreEqual("School", pCEventArgs.PropertyName);
}
Tuttavia, quando ho eseguito questo test dall'interno di Visual Studio con Testdriven.Net passa (è anche bene quando viene eseguito da una console app).
Quando non riesce con NUnit è perché PropertyChanged è nullo, subjectVM è una classe View Modello che eredita PropertyChanged da una classe base.
Sono io la colpa, o sto guardando un bug NUnit?
Soluzione
Diversi test harness effettuare prove in ordine diverso: se questo test ha una dipendenza implicito ordine di esecuzione del proiettore, potrebbe causare questo problema (ho bruciato da questo prima)
. La mia ipotesi migliore è che un altro test sta facendo qualcosa di sospetto a subjectVM
(o uno dei suoi i membri).