Sari Rahal
Sari Rahal

Reputation: 1955

NUnit Test project not finding any tests

I am new to NUnit testing and for some reason while trying to set up global variables, the program loses all references to all tests. I think it's because I am trying to create a global variable the wrong way. Any hint in the right direction would be helpful.

Here is a snipit of the code.

using System;
using JMS;
using System.IO;
using NUnit.Framework;

namespace JMSTest {

    [TestFixture]
    public class JMSTests {

    private JMSForm testJMS { get { return new JMSForm(); } }
    private string[] goodFileList = new string[] { ".DLD", ".STA", ".TIF", ".DFC", ".PDF" };
    private string[] ignoreFileList = new string[] { ".INI", ".RBK" };
    
    [Test]
    public void TestCreateConnectionStringBlank() {
        string testString = testJMS.createConnectionString("", "", "", "");

        Assert.AreEqual(testString, "server=;database=;uid=;password=");
    }

    [Test]
    public void TestCreateConnectionStringProper() {
        string testString = testJMS.createConnectionString("1", "2", "3", "4");

        Assert.AreEqual(testString, "server=1;database=2;uid=3;password=4");
    }

The results I get is:

------ Discover test started ------

========== Discover test finished: 0 found (0:00:00.037) ==========

I have also tried

public class JMSTests {

    private static JMSForm testJMS;
    private static string[] goodFileList;
    private static string[] ignoreFileList;

    [SetUpFixture]
    public class before_tests_run {
        [SetUp]
        public void ControllerASetup() {
            var testJMS = new JMSForm();
            var goodFileList = new string[] { ".DLD", ".STA", ".TIF", ".DFC", ".PDF" };
            var ignoreFileList = new string[] { ".INI", ".RBK" };
        }
    }

Upvotes: 0

Views: 54

Answers (1)

Khairul Islam
Khairul Islam

Reputation: 1215

If you're using a NUnit3+ version, there is a new Test Adapter available. Go to

Tools -> Extensions and Updates -> Online" and search for "NUnit3 Test Adapter

then install it. And then you will be able to run test.

Upvotes: 1

Related Questions