SDK needs test data files published with Samples - IMacro example Tests?

I'm trying to create some tests for my custom Macro.  I have the test running and reading the source file, generating a .tmp file but the tmp file doesn't match the gold.  In the documentation for the SDK, there's no mention of what the source file should look like.

A general plea for help, can we get test data samples included with the samples in the SDK?  I'm sure there's a lot of different file formats needed for actions, macros, etc...

5 comments
Comment actions Permalink

A slightly different idea occurred to me.  I can see some resistance to this, but what about you guys publishing the actual tests you have in-house for Resharper itself?

It doesn't have to be all of the tests, but it's probably an easier exercise for you guys to extract 1 test of each type from the Resharper tests than it would be for you to write new tests for the samples (which I'm assuming don't exist or they probably would have been published).

Thanks.

0
Comment actions Permalink

The SDK actually does ship with the *code* for the tests. It doesn't however, ship with the data files. It does include VS project item templates to make it easier to add the code for the tests, and the PsiPlugin and SamplePlugin samples in the SDK also include tests, with data files.

And the tests themselves generate files - you can take a .tmp file, manually check it, and if it's ok, rename it to .gold.

Also, have you seen this page from the devguide: http://confluence.jetbrains.com/display/ReSharper/2.10+Testing+%28R7%29

0
Comment actions Permalink

I saw the guide and it's pretty helpful for a lot of things.  I can also understand the workflow of running a test and tweaking until the .tmp file that's generated is what's expected, but I still don't know what the source data file should look like.  The missing piece of information in this case:

To create a macro test data file, how do I structure the source file to say "Run my macro here".

I've tried:

public class Thing : $macro$
{
}

As well as:

public class Thing : {caret}
{
}

But both just result in:

%% Evaluate result:
%% Evaluate quick result:
(None)
%% Evaluate lookup items:
(None)



It's not documented anywhere, and there doesn't seem to be an SDK sample that shows what the source data file should look like.  My immediate need is for macro tests, but I've also got Context Actions and Action Handlers I need to test.  Maybe there's sample data for those, I haven't got to looking yet.
0
Comment actions Permalink

It looks like your .cs file should be like:

public class Thing : {caret}
{
}

If you need to pass parameters to your macro, you can use ${PARAMETER:"dictionary"} in a comment at the top of the file. The text following the "%% Evaluate quick result:" is the string value of calling your IMacro.EvaluateQuickResult, or "(None)" if you return null. The text following "%% Evaluate lookup items:" is the DisplayName of each HotspotItem you return back from IMacro.GetLookupItems, or "(None)" if you return null.

If you load up the SDK bin folder in dotPeek, you can take a look at MacroTestBase to see exactly what's happening, but it's basically saving the return values of EvaluateQuickResult and GetLookupItems to the .tmp file and comparing that against what you say should be returned in the .gold file.

Let me know how you get on with this.

Thanks
Matt

0
Comment actions Permalink

It looks like that did the trick.  Not sure why that didn't work when I tried it the first time.

Thanks for the help.

One more note.  I have some actions I register in the VS#Solution and VS#Project menus via my actions.xml file.  I had to remove those insert elements to run my tests, otherwise I was gettnig an error about the item not existing.  I saw something about tests that rely on VS functionality, maybe I need to set that up, for now I just comment out those elements for testing, I just wanted to mention it in case it's an issue for others.

0

Please sign in to leave a comment.