I am new to C # and trying to write a simple Unit Test GUI with NUnit and NUnitForms. I want to check if clicking on a button opens a new form. My application has two forms: the main form (Form1) with a button that opens a new form (Password):
private void button2_Click(object sender, EventArgs e) { Password pw = new Password(); pw.Show(); }
The source of my test is as follows:
using NUnit.Framework; using NUnit.Extensions.Forms; namespace Foobar { [TestFixture] public class Form1Test : NUnitFormTest { [Test] public void TestNewForm() { Form1 f1 = new Form1(); f1.Show(); ExpectModal("Enter Password", "CloseDialog");
NUnit output:
NUnit.Extensions.Forms.FormsTestAssertionException : expected 1 invocations of modal, but was invoked 0 times (Form Caption = Enter Password)
Checking button text successfully. The problem is the ExpectModal method. I also tried it with the name of the form, but without success.
Does anyone know what could be wrong?
source share