首页 > 解决方案 > 在本地运行单元测试时缺少文件

问题描述

首先请记住,我只是发现“事物”在 DevOps 世界中是如何工作的,而且我的知识非常有限——尤其是在脚本(PS 和 C#)方面。

所以我必须弄清楚如何为应用程序设置一些 Javascript 单元测试——特别是让“测试结果分析器”小部件在 Jenkins 网站上启动和运行。

我目前正在从另一个 Jenkins 管道(def)回收代码,并使用项目的 makefile.include 中已经存在的“运行单元测试”阶段(根据项目的主要开发人员告诉我的内容)它从来没有工作过 - 从来没有测试 - 尝试让测试运行。

我认为最好的方法(不破坏主应用程序上的任何东西)是通过 cygwin 在本地进行测试。我已将项目映射为 Perforce 中的工作区,并尝试从 makefile.include 运行命令

$ make runRoutingPlannerCSTests

它正在工作大约一半,在它提示我一些丢失的文件错误之后,我无法在我的本地项目文件夹的任何地方找到这些错误。

CSC : error CS0006: Metadata file 'D:\src\project\ServicePlanning\BackendAPI\Comtec.Portal.OSPBackend.ApiModel\bin\Release\Comtec.Portnd [D:\src\project\ServicePlanning\Frontend_RoutingPlanner\Comtec.ServicePlanning.Frontend.RoutingPlanner.Tests\Comtec.ServicePlanning
CSC : error CS0006: Metadata file 'D:\src\project\ServicePlanning\Frontend_RoutingPlanner\Comtec.ServicePlanning.Frontend.RoutingPlannngPlanner.dll' could not be found [D:\src\project\ServicePlanning\Frontend_RoutingPlanner\Comtec.ServicePlanning.Frontend.RoutingPlanntingPlanner.Tests.csproj]
CSC : error CS0006: Metadata file 'D:\src\project\ServicePlanning\Frontend_RoutingPlanner\Comtec.ServicePlanning.Frontend.RoutingPlannFrontend.RoutingPlanner.Model.dll' could not be found [D:\src\project\ServicePlanning\Frontend_RoutingPlanner\Comtec.ServicePlanning.Flanning.Frontend.RoutingPlanner.Tests.csproj]
Makefile.include:121: recipe for target `buildRoutingPlannerCSTests' failed
make: *** [buildRoutingPlannerCSTests] Error 1

并且

$ make runTests

运行 Specrunner.html 后卡在某处

######################################################
# run unit tests
######################################################
runTests: runRoutingPlannerJasmineTests runRoutingPlannerCSTests

runRoutingPlannerJasmineTests:
    $(RoutingPlanner_TESTS_UTILITIES_DIR)/bin/phantomjs.exe $(RoutingPlanner_TESTS_DIR)/Scripts/jasmine.js $(RoutingPlanner_TESTS_DIR)/jsTests/SpecRunner.html

buildRoutingPlannerCSTests:
    $(MSBUILD) `cygpath -a -w $(RoutingPlanner_TESTS_DIR)/Comtec.ServicePlanning.Frontend.RoutingPlanner.Tests.csproj` $(MSBUILD_OPTIONS) /t:Build /property:Configuration=$(VS_CONFIG) /fileloggerparameters:LogFile=`cygpath -a -w $(RoutingPlanner_TESTS_DIR)/Comtec.ServicePlanning.Tests-Build-$(VS_CONFIG).log`

runRoutingPlannerCSTests: buildRoutingPlannerCSTests
    @rm -f '$(shell cygpath -aw '$(RoutingPlanner_TESTS_DIR)/bin/$(VS_CONFIG)/Comtec.ServicePlanning.Frontend.RoutingPlanner.Tests.trx')'
    $(DOTNET_UNIT_MSTEST) /nologo '/testcontainer:$(shell cygpath -aw '$(RoutingPlanner_TESTS_DIR)/bin/$(VS_CONFIG)/Comtec.ServicePlanning.Frontend.RoutingPlanner.Tests.dll')'  '/resultsfile:$(shell cygpath -aw '$(RoutingPlanner_TESTS_DIR)/bin/$(VS_CONFIG)/Comtec.ServicePlanning.Frontend.RoutingPlanner.Tests.trx')'

此部分在脚本的请求部分有一个附加部分,其中添加了路径。

RoutingPlanner_FRONTEND_API_DIR ?= $(RoutingPlanner_FRONTEND_DIR)/Comtec.ServicePlanning.Frontend.RoutingPlanner
RoutingPlanner_TESTS_DIR = $(RoutingPlanner_FRONTEND_DIR)/Comtec.ServicePlanning.Frontend.RoutingPlanner.Tests
RoutingPlanner_TESTS_UTILITIES_DIR = $(RoutingPlanner_TESTS_DIR)/Utilities/phantomjs-2.0.0-windows
RoutingPlanner_UTILITIES_DIR = $(PREPARESETUPDIR)/RoutingPlannerPortalUtilities 

老实说,我什至不确定我是否走在正确的道路上,因为我在互联网上找到的步骤与我在项目中找到的以及我认为应该做的不同。

例如:https ://wiki.jenkins.io/display/JENKINS/Test+Results+Analyzer+Plugin

主要是我认为这可能是一个简单的“错误路径”问题,但由于我的脚本技能接近于零,我不确定要修改什么以及在哪里修改。

我不指望手头的解决方案,但我真的很想了解问题是什么或实际完成这项工作的正确方法。

先感谢您。

标签: c#unit-testingjenkinsmakefilejenkins-pipeline

解决方案


推荐阅读