If I were faced with the task to migrate NUnit to MSTest I wouldn't use search-and-replace, but instead migrate it via temporary stubs. It would require me do several pretty easy steps:
- Remove references to nuint.framework.dll. I will get lots of red code, but we'll fix it in a minute.
- Add nunit.framework.dll source code to solution (if permitted by license), or write stubs for what I use, like TestFixture, Test, Setup and TearDown attributes and assertion classes. When I'm done with that, all code should be green again, which you can instantly verify with Solution Wide Analysis.
- Move all those types to MSTest namespaces.
- Rename types to match MSTest types.
- For assertions, implement missing members using existing API and use Inline Method refactoring to get rid of them.
- Remove stubs and add references to MSTest assemblies.
- Enjoy MSTest runner in ReSharper 4.5 to run your beloved tests.
Using this technique, or variation of it, you can easily migrate your source code to different API, library or technology, even if you don't have source code for it.
Develop with pleasure!
3 comments:
Nice refactoring trick. I wonder if the "quick fix" that is used to rename broken symbols could be used on a solution wide scale in the future. That could help in this case, since when you remove the references and the symbols no longer exist you could "find and replace" on the entire solution
This is very helpful. Also, thank you very much for the outstanding and timely VS2010 support!!
Helping people to migrate from one mocking framework to another (Rhino Mocks to Moq, NMock2 to Isolator, etc) might be an interesting and challenging task too :)
Post a Comment