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

Feature request - Create stubs for public methods #11 #28

Closed rCartoux closed 6 years ago

rCartoux commented 6 years ago
msftclas commented 6 years ago

CLA assistant check
All CLA requirements met.

RandomEngy commented 6 years ago

Amazing! Looking into it now, but at first glance seems quite solid.

rCartoux commented 6 years ago

Thanks! I am thinking now about some problems I didn't see:

rCartoux commented 6 years ago

Ok thanks! will do

RandomEngy commented 6 years ago

You're right, the "accepted tokens" list might need a bit of shuffling around. Also https://github.com/Microsoft/UnitTestBoilerplateGenerator/wiki/Custom-Format-Tokens will need an update.

RandomEngy commented 6 years ago

With your latest version I'm getting an exception when trying to generate from ClassWithMethods to VSTestCases:


System.NotSupportedException: Parameter type not supported

at UnitTestBoilerplate.Services.TestGenerationService.GetArgumentDescriptors(List1 argumentList, SemanticModel semanticModel, MockFramework mockFramework) in D:\git\UnitTestBoilerplateGenerator\src\Services\TestGenerationService.cs:line 324 at UnitTestBoilerplate.Services.TestGenerationService.<CollectTestGenerationContextAsync>d__9.MoveNext() in D:\git\UnitTestBoilerplateGenerator\src\Services\TestGenerationService.cs:line 238 --- End of stack trace from previous location where exception was thrown --- at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at System.Runtime.CompilerServices.TaskAwaiter1.GetResult() at UnitTestBoilerplate.Services.TestGenerationService.d15.MoveNext() in D:\git\UnitTestBoilerplateGenerator\src\Services\TestGenerationService.cs:line 343 --- End of stack trace from previous location where exception was thrown --- at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at System.Runtime.CompilerServices.TaskAwaiter`1.GetResult() at UnitTestBoilerplate.Services.TestGenerationService.d6.MoveNext() in D:\git\UnitTestBoilerplateGenerator\src\Services\TestGenerationService.cs:line 57 --- End of stack trace from previous location where exception was thrown --- at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at System.Runtime.CompilerServices.TaskAwaiter`1.GetResult() at UnitTestBoilerplate.ViewModel.CreateUnitTestBoilerplateViewModel.d__54.MoveNext() in D:\git\UnitTestBoilerplateGenerator\src\ViewModel\CreateUnitTestBoilerplateViewModel.cs:line 181 --- End of stack trace from previous location where exception was thrown --- at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at System.Runtime.CompilerServices.TaskAwaiter.GetResult() at UnitTestBoilerplate.ViewModel.CreateUnitTestBoilerplateViewModel.<b__53_0>d.MoveNext() in D:\git\UnitTestBoilerplateGenerator\src\ViewModel\CreateUnitTestBoilerplateViewModel.cs:line 166

rCartoux commented 6 years ago

Hi David, yes I just saw thx, I have a look

Robin

On 30 June 2018 at 14:06, David Rickard notifications@github.com wrote:

With your latest version I'm getting an exception when trying to generate from ClassWithMethods to VSTestCases:

System.NotSupportedException: Parameter type not supported

at UnitTestBoilerplate.Services.TestGenerationService. GetArgumentDescriptors(List1 argumentList, SemanticModel semanticModel, MockFramework mockFramework) in D:\git\UnitTestBoilerplateGenerator\ src\Services\TestGenerationService.cs:line 324 at UnitTestBoilerplate.Services.TestGenerationService.< CollectTestGenerationContextAsync>d9.MoveNext() in D:\git\ UnitTestBoilerplateGenerator\src\Services\TestGenerationService.cs:line 238 --- End of stack trace from previous location where exception was thrown --- at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) at System.Runtime.CompilerServices.TaskAwaiter. HandleNonSuccessAndDebuggerNotification(Task task) at System.Runtime. CompilerServices.TaskAwaiter1.GetResult() at UnitTestBoilerplate.Services.TestGenerationService.d15.MoveNext() in D:\git\UnitTestBoilerplateGenerator\src\Services\TestGenerationService.cs:line 343 --- End of stack trace from previous location where exception was thrown

at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) at System.Runtime.CompilerServices.TaskAwaiter. HandleNonSuccessAndDebuggerNotification(Task task) at System.Runtime.CompilerServices.TaskAwaiter1.GetResult() at UnitTestBoilerplate.Services.TestGenerationService.< GenerateUnitTestFileAsync>d6.MoveNext() in D:\git\ UnitTestBoilerplateGenerator\src\Services\TestGenerationService.cs:line 57 --- End of stack trace from previous location where exception was thrown --- at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) at System.Runtime.CompilerServices.TaskAwaiter. HandleNonSuccessAndDebuggerNotification(Task task) at System.Runtime. CompilerServices.TaskAwaiter1.GetResult() at UnitTestBoilerplate.ViewModel.CreateUnitTestBoilerplateViewModel.d54.MoveNext() in D:\git\UnitTestBoilerplateGenerator\src\ViewModel\ CreateUnitTestBoilerplateViewModel.cs:line 181 --- End of stack trace from previous location where exception was thrown

at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) at System.Runtime.CompilerServices.TaskAwaiter. HandleNonSuccessAndDebuggerNotification(Task task) at System.Runtime.CompilerServices.TaskAwaiter.GetResult() at UnitTestBoilerplate.ViewModel.CreateUnitTestBoilerplateViewModel.<<get_ CreateUnitTestCommand>b__53_0>d.MoveNext() in D:\git\ UnitTestBoilerplateGenerator\src\ViewModel\CreateUnitTestBoilerplateViewModel.cs:line 166

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/Microsoft/UnitTestBoilerplateGenerator/pull/28#issuecomment-401540145, or mute the thread https://github.com/notifications/unsubscribe-auth/AV8YZF3oy4D7PuGezXKovuZsY73VuaJ7ks5uB3fqgaJpZM4U1IK9 .

RandomEngy commented 6 years ago

Awesome! Can you re-run the self-test to update the expected output for the default method changes you made? And let me know when you're all done with the changes and I'll ship it.

rCartoux commented 6 years ago

Ok!

Unfortunately there are still some cases I need to check like arguments which are one or multidimensional arrays, params/ref/out modifiers etc

Then I ll do the test cases, maybe add some new ones. I let you know when its ready

Thx for the feedback

Cheers

On 30 June 2018 at 14:48, David Rickard notifications@github.com wrote:

Awesome! Can you re-run the self-test to update the expected output for the default method changes you made? And let me know when you're all done with the changes and I'll ship it.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/Microsoft/UnitTestBoilerplateGenerator/pull/28#issuecomment-401542393, or mute the thread https://github.com/notifications/unsubscribe-auth/AV8YZC1DCHppUQobsJpET7fbLOWl_WmUks5uB4GfgaJpZM4U1IK9 .

rCartoux commented 6 years ago

should be ok now

RandomEngy commented 6 years ago

Now getting this when I invoke the create unit test boilerplate option:

Nevermind, just needed to rebuild it seems. Looking good!
RandomEngy commented 6 years ago

Thanks again. Released with 1.9. Would you be able to also update the "tokens" wiki page? https://github.com/Microsoft/UnitTestBoilerplateGenerator/wiki/Custom-Format-Tokens

rCartoux commented 6 years ago

sure!

RandomEngy commented 6 years ago

Also a super easy way to help is rate it on the marketplace: https://marketplace.visualstudio.com/items?itemName=RandomEngy.UnitTestBoilerplateGenerator it only has a handful of reviews. There is a guy who hasn't updated his 1-star review months after I added xUnit support for him. :/

rCartoux commented 6 years ago

I have updated the custom format tokens page in my wiki fork : new TestMethods and TestedMethodName formats https://github.com/rCartoux/UnitTestBoilerplateGenerator-wiki

(not sure how to proceed with wiki issues / pull requests)

RandomEngy commented 6 years ago

I'll just copy/paste. Thanks!