Feature Request: "New from Template" for unit tests

It would be great if we could use a file template to create a TextFixture
class that has test methods, decorated with the Test attribute, for all public
members of a user-specified class. The body of each test could simply be
Assert.Fail.

Team System provides this kind of functionality for the MS-based test framework,
but I know of no such utility for NUnit tests. JetBrains should be the first!


4 comments
Comment actions Permalink

I agree this would be nice, although the templates are simple to create.

I think a much better option would be to provide support from R# to pick up templates from http locations (that you then elect to cache locally for use). Then we can all contribute to a set of community templates.

0
Comment actions Permalink

I agree this would be nice, although the templates are simple to
create.

I think a much better option would be to provide support from R# to
pick up templates from http locations (that you then elect to cache
locally for use). Then we can all contribute to a set of community
templates.


Would it really be simple to create a template that iterates over all the
public members of a type? Wouldn't that require a dialog to let the user
specify a type? Then control flow logic to use reflection and loop over the
public members and create a all the test methods? None of that seems doable
given the existing template macros, unless I am mistaken.

If you know of a way to do this, I am all ears.


0
Comment actions Permalink

Oops. That will teach me to read the question fully before answering :)

I had thought you meant a simple stub class with one/zero methods. I guess what you want may be achievable, but certainly with more effort that I mistakenly suggested.

0
Comment actions Permalink

Hello flipdoubt,

It is possible to write ReSharper plugin to achieve this very scenario. You
need to create Context Action, which will be available on type declaration,
enumerate members and create new file with required content. If you want
to do this - welcome to jetbrains.resharper.openapi newsgroup on news.intellij.net
server.

Sincerely,
Ilya Ryzhenkov

JetBrains, Inc
http://www.jetbrains.com
"Develop with pleasure!"


f> It would be great if we could use a file template to create a
f> TextFixture class that has test methods, decorated with the Test
f> attribute, for all public members of a user-specified class. The body
f> of each test could simply be Assert.Fail.
f>
f> Team System provides this kind of functionality for the MS-based test
f> framework, but I know of no such utility for NUnit tests. JetBrains
f> should be the first!
f>


0

Please sign in to leave a comment.