Thursday, 8 March 2012

Save project, run tests and open window to commit macro

I seem to always forgot to save my project when doing a commit to Mercurial so all my commits like like this...

hg commit -Am "Given a user is logged in, when they edit they're profile, then the profile is updated"
hg commit -Am "Project Saved"

I seem to be incapable of remembering to do this (although now I will probably always remember) so I made a little Macro to bring up the commit window instead of my current Visual Studio command. 

It's as simple to make Macros in Visual Studio as it is in any Office program. Just record the Macro (Tools, Macros) and then go in and tweak it if you need it (alt+F11, same as Office).  Mine is the following: 

    Sub SaveAllRunTestsOpenCommandPrompt()

        DTE.ExecuteCommand("File.SaveAll")

        DTE.ExecuteCommand("ReSharper.ReSharper_UnitTest_RunSolution")

        DTE.ExecuteCommand("Tools.ExternalCommand1")

    End Sub

The only non obvious thing here is the final command. This is an external command I set up (Tools, External Commands) opens up a command prompt in the folder containing the project. This means I can then commit the project or do a Wrap Update with OpenWrap. 

I assigned it the keyboard shortcut of ctrl+alt+s so that when I go to save all, it still saves all but it also runs all the tests in the solution, and opens the command window up in the right folder ready to commit. 

No comments:

Comments System

Disqus Shortname