Rider run Unity Unit Tests

1k views Asked by At

How can I run unity unit tests from Rider-EAP? It works fine from Unity.

I get this error when I try to run the tests:

Error:null: /Users/xxx/NavigationTest.sln :  error :
Target named 'Assembly-CSharp-Editor' not found in the project.

But I can build solution in Rider-EAP.

sln file from Unity:

Microsoft Visual Studio Solution File, Format Version 11.00
# Visual Studio 2008

Project("{6394337E-A760-107E-A1B5-972965181127}") = "NavigationTest", "Assembly-CSharp.csproj", "{09AAC607-4433-B8FC-AE7F-1AD11A119684}"
EndProject
Project("{6394337E-A760-107E-A1B5-972965181127}") = "NavigationTest", "Assembly-CSharp-Editor.csproj", "{E38ED05D-5652-068C-C70B-013EED402A29}"
EndProject
Global
    GlobalSection(SolutionConfigurationPlatforms) = preSolution
        Debug|Any CPU = Debug|Any CPU
        Release|Any CPU = Release|Any CPU
    EndGlobalSection
    GlobalSection(ProjectConfigurationPlatforms) = postSolution
        {09AAC607-4433-B8FC-AE7F-1AD11A119684}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
        {09AAC607-4433-B8FC-AE7F-1AD11A119684}.Debug|Any CPU.Build.0 = Debug|Any CPU
        {09AAC607-4433-B8FC-AE7F-1AD11A119684}.Release|Any CPU.ActiveCfg = Release|Any CPU
        {09AAC607-4433-B8FC-AE7F-1AD11A119684}.Release|Any CPU.Build.0 = Release|Any CPU
        {E38ED05D-5652-068C-C70B-013EED402A29}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
        {E38ED05D-5652-068C-C70B-013EED402A29}.Debug|Any CPU.Build.0 = Debug|Any CPU
        {E38ED05D-5652-068C-C70B-013EED402A29}.Release|Any CPU.ActiveCfg = Release|Any CPU
        {E38ED05D-5652-068C-C70B-013EED402A29}.Release|Any CPU.Build.0 = Release|Any CPU
    EndGlobalSection
    GlobalSection(SolutionProperties) = preSolution
        HideSolutionNode = FALSE
    EndGlobalSection
    GlobalSection(MonoDevelopProperties) = preSolution
        StartupItem = Assembly-CSharp.csproj
    EndGlobalSection
EndGlobal
1

There are 1 answers

1
ledneb On

Right-click your solution and click "Jump to source", or double-click the error to show the same thing. You'll get something like this:

# Visual Studio 2010
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "PROJECTNAME", "Assembly-CSharp.csproj", "{F9618595-3187-105D-65DC-297934AE12BE}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "PROJECTNAME", "Assembly-CSharp-Editor-firstpass.csproj", "{E7257D3B-0894-2E39-2141-C8FE4E9BCA6A}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Test", "Test\Test.csproj", "{C481669B-1E22-4D7C-8B33-7AB3A9D464FE}"
EndProject

The issue seems to be related to PROJECTNAME not equalling the project name. Rename the two PROJECTNAME entries to match their project:

# Visual Studio 2010
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Assembly-CSharp", "Assembly-CSharp.csproj", "{F9618595-3187-105D-65DC-297934AE12BE}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Assembly-CSharp-Editor-firstpass", "Assembly-CSharp-Editor-firstpass.csproj", "{E7257D3B-0894-2E39-2141-C8FE4E9BCA6A}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Test", "Test\Test.csproj", "{C481669B-1E22-4D7C-8B33-7AB3A9D464FE}"
EndProject

Then you might be able to run your tests.

This issue is discussed on GitHub and tracked by Jetbrains.

I did encounter this issue after applying this workaround, but as the issue suggests, running the tests a second time worked fine.