Disable all unit testing

Gilmore

Member
Joined
Apr 15, 2021
Messages
8
Programming Experience
10+
I am running Visual Studio Professional 2019 Version 16.11.2 I have an older project with perhaps 100 objects. VS suddenly started asking me to run Unit Tests. Although I understand the virtue of such testing, I just want to make some simple changes and am not interested in creating a bunch of unit tests right now. How can I totally turn off unit testing? All of the answers I can find apply to some specific package environment or address how to turn off specific tests and do not address this simple question.
 
Solution
OK. I have finally figured out what causes this issue and how to get around it. I suspect it initially arises because we have started using Github for change management. There is nothing wrong with Github. It's just that it changed things.

We have a Solution that is comprised of 4 Projects. When I start VS now the Startup Project is not set to the desired project. Instead, it will point to some code module or the entire Solution. I don't know how the choice is made, but it doesn't matter.

I need to go to the Solution Explorer and double-click on the Solution .sln file. This will expand the Solution file list. Now right-click on the desired Startup Project and select Set as Startup Project. The program will now run without asking for...

Gilmore

Member
Joined
Apr 15, 2021
Messages
8
Programming Experience
10+
Thanks for your input. I have seen that suggestion many times.

The question was, how do you disable Unit Testing altogether? I don't want to add an attribute to every object, tool, frame, panel, etc. I had been using VS for years and something made VS decide that I needed to do Unit Testing. How do I turn it off?
 

Skydiver

Staff member
Joined
Apr 6, 2019
Messages
3,555
Location
Chesapeake, VA
Programming Experience
10+
Presumably you work in a modern shop doing test driven development. In that case, you are supposed to write tests first before modifying the code.

Even if you aren't in an environment doing test driven development, wouldn't it make sense to write unit tests for each bit of code that you modify even if they are simple changes?

Anyway, I'm using VS2019 Professional v16.11.2 and I'm not getting prompted to create unit tests as I modify the code. I've tried modifying solutions where I have existing unit tests (but they are not full coverage -- e.g. not all classes have a unit test), as well as, solutions which are completely bereft of unit tests. Is there a chance that you have some kind of add-in or extension installed in VS2019 which is actually prompting you to create unit tests?
 

Skydiver

Staff member
Joined
Apr 6, 2019
Messages
3,555
Location
Chesapeake, VA
Programming Experience
10+
Or is the problem that you are running into the new "Live Unit Testing" feature of newer builds of VS2019 where it continuously is trying to run unit tests? If that's the case, go to Tools.Options... and search of "testing". That should bring up a pane that lets you enable/disable "Live Unit Testing".
 

Gilmore

Member
Joined
Apr 15, 2021
Messages
8
Programming Experience
10+
Presumably you work in a modern shop doing test driven development. In that case, you are supposed to write tests first before modifying the code.

Even if you aren't in an environment doing test driven development, wouldn't it make sense to write unit tests for each bit of code that you modify even if they are simple changes?

Anyway, I'm using VS2019 Professional v16.11.2 and I'm not getting prompted to create unit tests as I modify the code. I've tried modifying solutions where I have existing unit tests (but they are not full coverage -- e.g. not all classes have a unit test), as well as, solutions which are completely bereft of unit tests. Is there a chance that you have some kind of add-in or extension installed in VS2019 which is actually prompting you to create unit tests?
I do not work in a shop at all. I am a lone coder and I work with a guy who likes to tweak the GUI. We have been working on this project for about 8 years. It is a largely graphing application. I can't begin to imagine how one would write a Unit Test for a graph as it is largely visual.

Having said that, I have been involved with computers for over half a century. I retired from lecturing in the Computer Science department at UT Arlington in 2007. I co-authored a text in Operating Systems. I do not need a lecture on the virtues of Unit Testing. I have a stable application that needs some small tweaks. I do not want to take the time to make unit tests for an existing application with hundreds of components right now. I can do that later.

And VS is not suggesting that I create Unit Tests for the one element I changed. At least I don't think so. It is listing a ton of modules that need tests.

This is a pretty simple question. How do I tell Visual Studio on a global level that I do not want to run Unit Testing?
 

Attachments

  • OS BOOOK.jpg
    OS BOOOK.jpg
    24.5 KB · Views: 0
Last edited:

Gilmore

Member
Joined
Apr 15, 2021
Messages
8
Programming Experience
10+
Or is the problem that you are running into the new "Live Unit Testing" feature of newer builds of VS2019 where it continuously is trying to run unit tests? If that's the case, go to Tools.Options... and search of "testing". That should bring up a pane that lets you enable/disable "Live Unit Testing".
I am not running Live Unit Testing. All of the suggestions I have seen for disabling that do not apply because the options do noy even appear with my VS setup.
 

Skydiver

Staff member
Joined
Apr 6, 2019
Messages
3,555
Location
Chesapeake, VA
Programming Experience
10+
I do not work in a shop at all. I am a lone coder and I work with a guy who likes to tweak the GUI. We have been working on this project for about 8 years. It is a largely graphing application. I can't begin to imagine how one would write a Unit Test for a graph as it is largely visual.
Unit tests can be written against the View of an application written with the MVC or MVP pattern using dependency injection where the actual interface to the UI is mocked.

Having said that, I have been involved with computers for over half a century. I retired from lecturing in the Computer Science department at UT Arlington in 2007. I co-authored a text in Operating Systems.
What does having written a book about OSes have to do with not following modern best practices? I was just telling you what good software engineering practices dictate.

I have a stable application that needs some small tweaks. I do not want to take the time to make unit tests for an existing application with hundreds of components right now. I can do that later.

And VS is not suggesting that I create Unit Tests for the one element I changed. At least I don't think so. It is listing a ton of modules that need tests.
Can you show a screenshot where it is doing this? Is it in the Errors and Warning pane? If so, what error/warning code is it listing? If there is such an error code or warning listed then you can typically suppress the generation of that error/warning by adding a property in the .csproj if I recall correctly.
 

Gilmore

Member
Joined
Apr 15, 2021
Messages
8
Programming Experience
10+
OK. I have finally figured out what causes this issue and how to get around it. I suspect it initially arises because we have started using Github for change management. There is nothing wrong with Github. It's just that it changed things.

We have a Solution that is comprised of 4 Projects. When I start VS now the Startup Project is not set to the desired project. Instead, it will point to some code module or the entire Solution. I don't know how the choice is made, but it doesn't matter.

I need to go to the Solution Explorer and double-click on the Solution .sln file. This will expand the Solution file list. Now right-click on the desired Startup Project and select Set as Startup Project. The program will now run without asking for Unit Testing. If this isn't clear, contact me and I will include some screenshots.

Thanks for all the lectures on the virtues of Unit Testing, although they were irrelevant to my question. Rest assured that I will work on that. But now was not the time.

Hope this helps someone else, and I hope you have a nice weekend.
 
Solution

Skydiver

Staff member
Joined
Apr 6, 2019
Messages
3,555
Location
Chesapeake, VA
Programming Experience
10+
Glad you found the root cause.

This may or may not help for your shared project to "force" the startup solution for code that is cloned fresh from Github where the fresh clone doesn't have the appropriately ignored .vs directory:
 
Top Bottom