microsoft / UnitTestBoilerplateGenerator

An extension for Visual Studio that generates a unit test boilerplate from a given class, setting up mocks for all dependencies. Supports NUnit, Visual Studio Test, Moq and SimpleStubs.
MIT License
158 stars 51 forks source link

Crashes when testfile already exists #51

Open digitalsigi opened 4 years ago

digitalsigi commented 4 years ago

Installed product versions

Description

Crashes with 'File already exists' when test file already exists

Steps to recreate

  1. Have a Test project already in place with a Class File named as being generated from tool
  2. right click on class file for which test should be generated
  3. confirm "Generate Unit Test"
  4. Crash

Current behavior

Obviously doesn't check whether the file exists See screenshot: image

Expected behavior

Should check whether file exists and prompt to confirm overwrite

RandomEngy commented 4 years ago

It does check to see if the file is there. It's just that my error reporting is a little lazy and I just throw all problems at a central exception handler.

I'm wary of the need to overwrite the previous file as there is likely some work that would be lost if that happened. The tool is used mostly for creating a fresh blank template for tests.

digitalsigi commented 4 years ago

Actually I wanted to overwrite the existing file, because I first generated it from right click on method and selecting there "create test" before I installed your solution. This is why I want it to get overwritten. Its not a problem, workaround is to delete the file.