■ サンプルコード
* デザイン([NUnitFormSample]-[NUnitSampleForm.cs])とは 別プロジェクト(以下の例では「FormTest」)で、テストクラスを記述する
コード
using NUnit.Extensions.Forms; using NUnit.Framework; using NUnitFormSample; namespace FormTest { [TestFixture] public class NUnitFormTest { private NUnitSampleForm _form; [SetUp] public void SetUp() // 前処理 { // テスト対象画面の表示 this._form = new NUnitSampleForm(); this._form.Show(); } [TearDown] public void TearDown() // 後処理 { this._form.Close(); } [Test] public void Test1() { TextBoxTester textTester = new TextBoxTester("textBox1"); Assert.AreEqual(string.Empty, textTester.Text); Assert.AreEqual(255, textTester["MaxLength"]); } [Test] public void Test2() { // 検索ボタンを押下 ButtonTester buttonTester = new ButtonTester("button1"); buttonTester.Click(); TextBoxTester textTester = new TextBoxTester("textBox1"); Assert.AreEqual("Hello world!", textTester.Text); } } }
参考資料
http://www.atmarkit.co.jp/fdotnet/nagile/nagile03/nagile03_02.htmlhttp://www.tdd-net.jp/cs2008ee-nunit-25-helloworld.html
http://dora.bk.tsukuba.ac.jp/~takeuchi/index.php?%A5%D7%A5%ED%A5%B0%A5%E9%A5%DF%A5%F3%A5%B0%2F%A3%C3%A1%F4%2FExpress%20Edition%20%A4%C7%A4%CE%A5%C6%A5%B9%A5%C8%B6%EE%C6%B0%B7%BF%B3%AB%C8%AF