Am I overlooking something?

Help
2008-05-01
2013-04-24
  • Kurtis Mullins

    Kurtis Mullins - 2008-05-01

    Hello,

    First off, I'm new to automated testing, so please forgive me if my questions sound ignorant. I am very interested in using NUnitForms.

    I created a very simple C# application to test and added some code to test it. After a few hours of reading various web site postings and the docs as well as tinkering with the code, I managed to create a successful build. Using VS2005, the project creates 1 .exe file and imports the 2 .dll files from NUnitForms. I tested around with various ways of doing things and I believe at one point it even created its own .dll file.

    The problem I am running into is, how do I test this application using my embedded code? I tried to open different files using the NUnitForms Player but nothing would open(.exe,.dll). From reading through the Forums, I think I found a post or two that shows the Player as defunctional. If this is the case, how do most people use NUnitForms to test?

    If anyone would be willing to write a very simple C# form in VS2006 that includes a little bit of beginner testing code, that would be awesome too.

    Thanks Ahead

    -Kurtis Mullins

     
    • Anders Lillrank

      Anders Lillrank - 2008-05-02

      Hi!

      This is a short example how you could do.

      1. Create a WindowsApp project.
      2. In the default generated From1 add a button named button1 and a textbox callted textbox1.
      3. implement a callback for button click and in that set the textbox to Hello (Just as an example)

      using System;
      using System.Collections.Generic;
      using System.ComponentModel;
      using System.Data;
      using System.Drawing;
      using System.Text;
      using System.Windows.Forms;

      namespace WindowsApplication2
      {
          public partial class Form1 : Form
          {
              public Form1()
              {
                  InitializeComponent();
              }

              private void button1_Click(object sender, EventArgs e)
              {
                  textBox1.Text = "Hello";
              }
          }
      }

      4. add references to NunitForms and nunit.framework
      5. Create a test class like the following

      using System;
      using System.Collections.Generic;
      using System.Text;
      using NUnit.Extensions.Forms;
      using NUnit.Framework;

      namespace WindowsApplication2
      {
          [TestFixture]
          public class UnitTester
          {
              [Test]
              public void TestButton()
              {
                  Form1 frm = new Form1();
                  frm.Show();

                  ButtonTester btnTester = new ButtonTester("button1");
                  btnTester.Click();

                  TextBoxTester tbText = new TextBoxTester("textBox1");
                  Assert.AreEqual("Hello", tbText.Text);
              }
          }
      }

      6. Build the app and start NUnit gui. Load the .exe  and you should be able to se the
         test "TestButton" function.

      This is how ever not the way im using NUnitforms because then your app will be dependent on NUnit and NUnitforms. I Usually put my gui in a separate dll and then i create a separate project for the tests. Then my application will not dependent on NUnit.

      Hope this helps

      /Anders

       

Log in to post a comment.

Get latest updates about Open Source Projects, Conferences and News.

Sign up for the SourceForge newsletter:

JavaScript is required for this form.





No, thanks