简体   繁体   English

车手运行Unity单元测试

[英]Rider run Unity Unit Tests

How can I run unity unit tests from Rider-EAP? 如何从Rider-EAP运行统一单元测试? It works fine from Unity. 从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. 但是我可以在Rider-EAP中构建解决方案。

sln file from Unity: 来自Unity的sln文件:

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

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. 该问题似乎与PROJECTNAME不等于项目名称有关。 Rename the two PROJECTNAME entries to match their project: 重命名两个PROJECTNAME条目以匹配其项目:

# 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 . 这个问题在GitHub上讨论, 并由Jetbrains跟踪

I did encounter this issue after applying this workaround, but as the issue suggests, running the tests a second time worked fine. 应用此替代方法后,我确实遇到了此问题 ,但是正如问题所表明的,第二次运行测试效果很好。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM