Member Avatar for loserspearl
loserspearl

I've been writing a project in C# using VS2010 .Net 4.0 on my project and am trying to do NUnit testing (version 2.6) which I haven't done before.

I added the nunit.framework reference to my project and created a test class:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace AcceleratedAptitude
{
    using NUnit.Framework;

    [TestFixture]
    class GeneratorTest
    {
        public Solver solv;
        public ProblemGenerator probGen;

        [TestFixtureSetUp]
        public void SetUp()
        {
            probGen = new ProblemGenerator();
            solv = new Solver();
        }

        //math problem generator tests
        //can generate Int
        //can gen double
        //can gen paren
        //can gen fract

        //can add/sub
        [Test]
        public void addSubTest()
        {
            Assert.That(solv.Evaluate("3+8-5"), Is.EqualTo(3 + 8 - 5));
            Assert.That(solv.Evaluate("5-8+3"), Is.EqualTo(5 - 8 + 3));
        }

        //can multDiv
        [Test]
        public void multDivTest()
        {
            Assert.That(solv.Evaluate("6*8/4"), Is.EqualTo(6 * 3 / 2));
            Assert.That(solv.Evaluate("4/8*6"), Is.EqualTo(4 / 8 * 6));
        }

        //can parenOoP
        [Test]
        public void parenTest()
        {
            Assert.That(solv.Evaluate("4+(4*3)-8/2"), Is.EqualTo(4 + (4 * 3) - 8 / 2));
            Assert.That(solv.Evaluate("2/8-(3*4)+4"), Is.EqualTo(2 / 8 - (3 * 4) + 4));
        }
    }
}

No errors yet, I open nunit-x86(same error for non x86) use it to open my visual studio project .exe file @ AcceleratedAptitude\bin\Debug

Right away I get 'assembly not built with any known testing framework' not surprising. I check my test assemblies under tools and it shows:
nunit-x86.exe ( 786984 )
Framework Version: Net 3.5
CLR Version: 2.0.50727.5456

Even though my project's target framework is 4.0 (I'm using expression trees and tuples), I go to project->edit and change the runtime to 4.0 and it changes to:
nunit.exe ( 789084 )
Framework Version: Net 3.5
CLR Version: 2.0.50727.5456

nunit-agent.exe ( 788768 )
Framework Version: Net 4.0
CLR Version: 4.0.30319.269

But it still doesn't recognize my test class and even after saving and reopening it reverts the runtime to 2.0 (I've tried changing the config file to force 4.0 it says access denied even though I'm admin). I've used JUnit(with netbeans) before but never had a issue like this, what am I doing wrong?

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.