machine / machine.specifications

Machine.Specifications is a Context/Specification framework for .NET that removes language noise and simplifies tests.
MIT License
885 stars 178 forks source link

Test Runner for Rider IDE #330

Closed ASalihov closed 5 years ago

ASalihov commented 7 years ago

Do you have plans to develop test Runner for Rider IDE? This would be great!

ivanz commented 7 years ago

No immediate plans myself (I don't use Rider), but given that we have a ReSharper runner plugin - I wonder a) if that's compatible somehow or b) if it's easy to multi-target/port the ReSharper runner for Rider. Caveat here is that the ReSharper runner doesn't yet support .NET Core - see https://github.com/machine/machine.specifications.runner.resharper/issues/46

ivanz commented 7 years ago

Had a quick look around and it looks like currently there is no SDK for building "backend" plugins (Resharper host runs in the backend since the frontend is JVM). Appears that this is tracked here: https://youtrack.jetbrains.com/issue/RIDER-7477 and it looks like we may be able to package the ReSharper plugin as a Rider plugin in the future.

citizenmatt commented 7 years ago

Yep, there's no SDK just yet, but it's coming. Hopefully, it should Just Work after a recompile and repackaging. But unit testing support in Rider is complex, and we haven't tested extending it with a new plugin, so there's a chance of issues.

kamilbudziewski commented 6 years ago

@citizenmatt Any news on that one? :)

citizenmatt commented 6 years ago

Good news and bad news :) The good news is that there's an SDK available. The bad news is that it's completely undocumented and a bit of a manual process.

To build the "backend" plugin for the headless ReSharper process, you just need to create a new project, reference the JetBrains.Rider.SDK package and recompile. This will work for the majority of plugins, unless you're doing something interesting, such as UI, or extending a part of ReSharper that isn't yet supported in Rider.

But, Rider is an IntelliJ based IDE, so plugins need to be IntelliJ plugins. This means creating a .jar file (actually just a .zip file) which contains a manifest file with metadata, and also contains the .nupkg file that packages up the Rider version of the ReSharper extension.

It's also possible to add frontend code into this IntelliJ plugin (display dialogs, interact with IntelliJ extension points, etc.) or it can be completely empty.

Here's an example of a ReSharper plugin that's been ported to work with Rider. This section of build.ps1 will build the Rider compatible .nupkg, set up a directory structure and then it SHOULD zip up the files. Unfortunately, the .NET zip classes do something funky to the .zip file and IntelliJ can't read them. I have no idea what, so I just zip it manually. There are comments there about the directory structure you need (pay attention to this - this is easy to get wrong). And then you need to create a plugin.xml file that provides just enough metadata to display in the IntelliJ plugin preferences page.

You can test it by installing directly from disk in Rider's plugin pages, and once you're done, you can upload it to the JetBrains plugin repository - NOT the ReSharper plugin gallery.

(Note that you can automate things. This is probably best done using Gradle, and the gradle-intellij-plugin, which is a plugin to Gradle that tells it how to build IntelliJ plugins. This allows for building the .jar/.zip correctly and running a "sandbox" instance of Rider that only has your plugin installed. This is what we do with the Unity plugin, but because we automate more things than that, we end up with a build.gradle (and associated frontend and backend files) that are more complicated than you'd need for a quick example).

BrunoJuchli commented 6 years ago

How about using xunit to run mspec tests? Xunit v2 is quite extensible... IMO this would make maintenance much easier.

Instead of writing a new runner for Rider, this would require @citizenmatt to implement xunit v2 discovery in Resharper and Rider. See here.

It would also open up a lot of other new possibilities. Not related to mspec.

dbones commented 5 years ago

not sure what this is supposed to be

https://plugins.jetbrains.com/plugin/11006-machine-specifications-runner-for-rider

i have not been able to make this work, my copy of rider says it is not a recognised plugin

robertcoltheart commented 5 years ago

An official Rider plugin has been published to https://plugins.jetbrains.com/plugin/11528-machine-specifications-for-rider

Next step is to integrate it into our builds.