help_eachother

Hi,

I am trying to configure NUnit 2.4.3 with Visual C# project.

Although i am able to build the project with the test cases, but when i run the assembly in NUnit GUI it is giving me the f

following message.

"The assembly was not built with a known framework"

I have already specified the reference of NUnit dll,

Can anybody guide me , what can be wrong.



Re: Visual C# General Configuring NUnit with Visual C# project

Peter Ritchie

You have to attribute various methods for Nunit to detect them. For example:

Code Snippet

using NUnit.Framework;

[TestFixture()]

public class Tester

{

[Test()]

public void Method()

{

// TODO: something

}

}

Add a reference to your project to NUnit.Framework.dll, if you haven't already.




Re: Visual C# General Configuring NUnit with Visual C# project

OmegaMan

There are different versions of Nunit which target specific .Net frameworks of .Net 1.1 and 2/3. Make sure if you are using .Net 1.1, then you are using the .Net 1.1 version of Nunit. If you are using .Net 2/3 make sure you are using the .Net 2 version of Nunit. I don't believe they support .Net 3.5(beta) at this time. See the Nunit download page Downloads.




Re: Visual C# General Configuring NUnit with Visual C# project

help_eachother

Hi,

I am using VIsual Studio and NUnit 2.4.3. and i think they both are compatible.

Please correct me if i am wrong in my assumption.

I have written the test correctly so i am little amazed why it is not working.





Re: Visual C# General Configuring NUnit with Visual C# project

Peter Ritchie

There's two versions of NUnit 2.4.3, one for .NET 1.1 (Visual Studio 2003) and one for .NET 2.0 (Visual Studio 2005). See http://www.nunit.org/index.php p=download for links to the downloads of each version.




Re: Visual C# General Configuring NUnit with Visual C# project

help_eachother

Hi,

I have already downloaded the correct version (NUnit-2.4.3-net-2.0 msi) but i am not able to run the test.





Re: Visual C# General Configuring NUnit with Visual C# project

Peter Ritchie

Can you post some code where you've declared your test, setup and teardown methods






Re: Visual C# General Configuring NUnit with Visual C# project

OmegaMan

help_eachother wrote:
I am using VIsual Studio and NUnit 2.4.3. and i think they both are compatible.


I know I am splitting hairs here, but which version of Visual Studio 2.4.3 only works with VS2005 and not VS2003. Thanks.





Re: Visual C# General Configuring NUnit with Visual C# project

help_eachother

Hi,

I am using VS 2005.

My code is

Simple.cs

Code Snippet

using System;

using System.Diagnostics;

namespace example

{

///

/// Summary description for Simple.

///

public class Simple

{

public Simple() { }

public int AddPositive(int arg1, int arg2)

{

Debug.Assert(arg1 > -1 && arg2 > -1);

return arg1 + arg2;

}

public int AddNegative(int arg1, int arg2)

{

throw new Exception("not implemented yet");

}

public void Dispose() { }

}

}

SimpleTest.cs

Code Snippet

using System;

using NUnit.Framework;

namespace example

{

/// <summary>

/// Summary description for SimpleTests.

/// </summary>

[TestFixture]

public class SimpleTests

{

[SetUp]

public void SetUp()

{

_mySimple = new Simple();

// put other startup code here

}

[TearDown]

public void CleanUp()

{

_mySimple.Dispose(); // assumes Disposable is implemented

_mySimple = null;

//put other cleanup code here

}

[Test]

public void TestAddPositiveMethod()

{

Assert.AreEqual(_mySimple.AddPositive(2, 3), 5);

Assert.AreEqual(_mySimple.AddPositive(0, 3), 3);

Assert.AreEqual(_mySimple.AddPositive(2, 0), 0);

Assert.AreEqual(_mySimple.AddPositive(0, 0), 0);

}

[Test]

[ExpectedException(typeof(Exception))]

public void TestAddNegative()

{

Assert.AreEqual(_mySimple.AddNegative(-5, 0), -5);

}

[Test]

[Ignore("Implementation not complete yet.")]

public void MyThirdTest()

{

// your test implementation goes here

}

private Simple _mySimple = null;

}

}





Re: Visual C# General Configuring NUnit with Visual C# project

Peter Ritchie

I copied your code into an application and loaded the assembly with nunit.exe and had no problems.




Re: Visual C# General Configuring NUnit with Visual C# project

help_eachother

But why its not working on my machine.

Any idea..............





Re: Visual C# General Configuring NUnit with Visual C# project

Peter Ritchie

You could try loading your assembly into Reflector to see if the attributes are on methods. Once in Reflector, clicking on the attribute for a method will hyperlink you to that type so you can verify that it's using an NUnit type.






Re: Visual C# General Configuring NUnit with Visual C# project

OmegaMan

help_eachother wrote:

But why its not working on my machine.

Any idea..............



Are you using the Nunit GUI or command line The nunit requires an Nunit project to be created, the gui will default to the last project...any chance you are running the wrong project Or the project points to the release assembly which is old

Maybe create a new project and point to the debug/release version you are currently running might shed some light on the issue.