I am attempting to automate tests using Nunit and have loaded a project from Visual Studio. I do not understand how to delete Tests i do not want in my project. I know I can choose not to run tests but when i am automating the tests I will need some of them to be gone completely. I have checked the Nunit documentation and googled this question and have yet to find the answer. I do not want to use additional third party tools. Can anyone help with this question?
Asked
Active
Viewed 377 times
0
-
This needs way more information. It's very unclear on what you are trying to do. You have Test A and B. You mean that sometimes you only want to run test B but not A? – Arran Dec 09 '14 at 22:25
-
Arran its one question How do I delete tests in Nunit. Its Clear. – user1622681 Dec 10 '14 at 23:20
-
No it's not. Delete tests? Well delete the code. Delete them how? Keep the code but not run them? When do you want to run them? – Arran Dec 10 '14 at 23:22
-
I want to delete them in the Nunit console. – user1622681 Dec 10 '14 at 23:24
-
That isn't possible because it simply isn't what the console is there to do. If you want the tests gone, either remove the code or place an `[Ignore]` over them. – Arran Dec 10 '14 at 23:27
2 Answers
0
Your test probably looks something like this...
[TestFixture]
public class Tests()
{
[Test]
public TestYouWantToDelete()
{
\\ You Test Code
}
}
Remove
[Test]
public TestYouWantToDelete()
{
\\ You Test Code
}
You could also comment it out and it wouldn't be picked up by the testrunner.
Also you could change the Assert to Assert.Ignore();
if you might want to get it working again later.

Matt McCabe
- 2,986
- 2
- 22
- 29
-
Matt I am using a Script from Visual Studio I am not using any of the above.I loaded a csproj file. Where do i edit this information from? Do I have to change the code in the VS project and then copy paste it back over to this vm? – user1622681 Dec 09 '14 at 20:47
0
Simply comment the [Test]
attribute. Something like the following:
[TestFixture]
public class TestsFixture()
{
//[Test]
public TestYouWantToDelete()
{
\\ You Test Code
}
}
without [Test]
attribute test code doesn't have any value. It will not simply run

Saifur
- 16,081
- 6
- 49
- 73