← Back to team overview

nunit-core team mailing list archive

[Question #108758]: best practice to re-execute a test suite with another parameter common to all tests

 

New question #108758 on NUnit Framework:
https://answers.launchpad.net/nunit-3.0/+question/108758

i am not sure i'm posting in the right place, but we'll see.

in the early 2000s in was coding some java / c++, then spent most of the previous years on ruby/php and more recently i have to endure some C#. more precisely using a third party dll within C# program.
This lib isn't precisely reliable so i would like some of its basic features automatically tested. I figured Nunit was probably a nice approach. I have been able to produce some tests and i have been pretty happy about them compared to what i've been doing with php/ruby.

Now I have something like

namespace NunitStupidDLL {

    [TestFixture]
    public class TestStupidDLL {
        
        protected String ipAdress   = "192.165.0.66";
        protected String port       = "8888";

        [Test]
        public void test_one_thing() {            
            // ....
            Assert.AreEqual( ... , ... , "should be equal");
        }

        [Test]
        public void test_something_else() {            
            // ....
            Assert.AreEqual( ... , ... , "should be equal too");
        }
}
(sorry for the lame naming conventions of test names :))

i have been using Nunit gui so far (*) 

i want to reuse the same test but using another ip, another port, etc. (a parameter that is common to all tests)
+ I want the way tests work to be readable, easy to maintain, and the whole thing nicely displayed in the GUI

so putting
[TestCase("192.168.0.55", "8888")]
[TestCase("192.168.0.166", "8881")]
in front of every single test does not seem to the right way (i hate to repeat myself)

using the Suite attribute doesnt quite seem to be the solution either (http://www.nunit.org/index.php?p=suite&r=2.5.5 seems to discourage programmers from this approach)

I must be missing something i think

What is the best practice / approach to reuse an already written test scenario so that I re-run it entirely using just another parameter + that it displays nicely within the gui ?

thanks
fourchette

(*) but i am thinking of using the command line to harness the dll with data driven test once i'm getting more familiar with the tool

-- 
You received this question notification because you are a member of
NUnit Core Developers, which is an answer contact for NUnit Framework.