Creating a template for MSTest TestMethod
Hi,
I am trying to create a small template that builds the skeletton for our TestMethods, based on the naming conventions we use on the project.
Our conventions expect our TestMethods to look like this :
TestMethod] public void PublicationProcess_Execute_with_no_changes_returns_zero() { // Arrange var p = new PublicationProcess(); // Act var result = p.Execute(); // Assert Assert.Inconclusive("EDITME : Assert returns zero for PublicationProcess.Execute() with no changes"); }
typically the big blocks would be :
-tested_class (in that case PublicationProcess)
-tested_method (a method defined for this type)
-test_conditions ( "no changes")
-expected outcome "returns zero"
I would like the user to (in that order) :
-type the Type to test (with completion)
-type the method to test (with completation of possible methods of the selected type)
-type the test condistions with spaces, and this should update the TestMethod name replacing spaces with underscores
-type the expected output with spaces, and this should update the TestMethod name replacing spaces with underscores
I could more or less get the first parts, but using the template seems to fail if I include the variable in a comment : as soon as a start typing one of the variables that are included in the comment, I can no longer access the next variables
[Microsoft.VisualStudio.TestTools.UnitTesting.TestMethodAttribute]
public void $tested_object$_$tested_method$_with_$test_conditions$_$expected_result$()
{
// Arrange
var o = new $tested_object$();
// initial conditions : $test_conditions_with_spaces$
$END$
// Act
var res = o.$tested_method$();
// Assert
// TODO : check that: $expected_result_with_spaces$
Assert.Inconclusive("TODO: $expected_result_with_spaces$ for $tested_object$.$tested_method$() with $test_conditions_with_spaces$");
}
Any idea what can be going wrong ?
I attach an exportation of my template
Thanks in advance !
Attachment(s):
aaa_TestMethod.xml
Please sign in to leave a comment.
Hello Thibaud,
This seems to be a bug in ReSharper 6.0 which should get fixed in the upcoming
ReSharper 6.1. Thank you!
Andrey Serebryansky
Senior Support Engineer
JetBrains, Inc
http://www.jetbrains.com
"Develop with pleasure!"
OK, I'll wait then.
Thanks for a quick reply !