Forum Discussion

fc09's avatar
fc09
New Contributor
4 years ago

Run a single NUnit test from TestComplete

Hi

 

I am trying to run a single NUnit test from within TestComplete, but I am having some difficulties. I don't want to run all the tests in the .net assembly, just a single one.

 

I have created a unit test item in my project and in the 'Advanced parameters' field, I have entered "--test Demo.Tests.Test2".

 

This should run only the test named 'Test2' within the 'Demo.Tests' class - this is exactly what happens if I use the NUnit console runner by itself, and I expected the same behaviour from TestComplete, as I gather it uses the console runner behind the scenes.

 

However, the actual behaviour I get is somewhat bizarre. TestComplete seems to call the test runner for each test in the assembly separately, and applies my filter to every single run. From the test log we can see that TestComplete has tried to run both Demo.Tests.Test1 and Demo.Tests.Test2.

 

If I view the details of the execution for Test1, I can see that TestComplete has applied my filter for Test2, but has also applied its own filter for Test1. This results in both Test1 and Test2 being executed on this run.

 

Then if I look at the details for the execution of Test2, I can see that TestComplete has applied my Test2 filter, as well as its own Test2 filter. This means Test2 is executed again.

 

Presumably, if I had a Test3 in my test fixture, it would then go on to a third run, and apply filters for Test3 and Test2, and so on.

 

What I want to accomplish is very simple - I just want to execute Demo.Tests.Test2 once, and no other test. Is there any way I can do this, because I haven't been able to find any obvious solution.

 

I have also tried using --where "test == Demo.Test.Test2" as my filter, but this also seems to cause a strange result. As before, it tries to run every single test individually, but also applies the 'where' filter in each case, meaning that none of the test runs do anything, except the one meant for Test2. This causes an indeterminate result for all of the tests except Test2. I don't want this cluttering up my test log/reports - if I want to run a single test, and that particular test passes, I just want to see a single 'pass' in my log.

 

For a bit of background, the reason I want to run a single NUnit test is because we are testing a system which incorporates two main applications, one of which is a web application, with the other being a native desktop application. We already have a Selenium framework to test the web application, but many of our tests involve using both the web and desktop applications. We want to be able to create a TestComplete test which utilises the existing Selenium framework for the web parts, which would involve running a specific NUnit test designed for that particular scenario, rather than running the whole suite of tests.

 

Any help with this would be very much appreciated.