在选择表达异常标记“”在3位(Unexpected token '' at posi

2019-09-29 21:09发布

我在执行詹金斯作业批处理脚本。

C:\Users\Administrator\AppData\Local\Apps\OpenCover\OpenCover.Console.exe "-target:C:\Program Files (x86)\NUnit.org\nunit-console\nunit3-console.exe" "-targetargs:C:\Test\src\Example.Tests\bin\Debug\example.Tests.dll --where "cat == Unit" -register:Administrator

我使用的过滤器,以及,但没有用。

C:\Users\Administrator\AppData\Local\Apps\OpenCover\OpenCover.Console.exe "-target:C:\Program Files (x86)\NUnit.org\nunit-console\nunit3-console.exe" "-targetargs:C:\Test\src\Example.Tests\bin\Debug\example.Tests.dl -filter:"+[Unit]*" -register:Administrator

此批处理命令有一个WHERE条件(--where“猫==单位”)。 当我执行此我得到下面的错误。

测试文件

  C:\Test\src\Example.Tests\bin\Debug\example.Tests.dll
    ==
    Unit

Test Filters
    Where: cat

Unexpected token '' at position 3 in selection expression.
Committing...
No results, this could be for a number of reasons. The most common reasons are:
    1) missing PDBs for the assemblies that match the filter please review the
    output file and refer to the Usage guide (Usage.rtf) about filters.
    2) the profiler may not be registered correctly, please refer to the Usage
    guide and the -register switch.

由于此错误,我无法获取代码覆盖率。 请suggest.I发现下面的链接,但我无法完成这件事。

https://github.com/codecov/example-csharp

更新错误日志。

Incorrect Arguments: The argument 'cat == Unit' is not recognised

Usage:
    ["]-target:<target application>["]
    [["]-targetdir:<target directory>["]]
    [["]-searchdirs:<additional PDB directory>[;<additional PDB directory>][;<additional PDB directory>]["]]
    [["]-targetargs:<arguments for the target process>["]]
    [-register[:user]]
    [["]-output:<path to file>["]]
    [-mergeoutput
    [["]-filter:<space separated filters>["]]
    [["]-filterfile:<path to file>["]]
    [-nodefaultfilters]
    [-regex]
    [-mergebyhash]
    [-showunvisited]
    [-returntargetcode[:<opencoverreturncodeoffset>]]
    [-excludebyattribute:<filter>[;<filter>][;<filter>]]
    [-excludebyfile:<filter>[;<filter>][;<filter>]]
    [-coverbytest:<filter>[;<filter>][;<filter>]]
    [["]-excludedirs:<excludedir>[;<excludedir>][;<excludedir>]["]]
    [-hideskipped:File|Filter|Attribute|MissingPdb|All,[File|Filter|Attribute|MissingPdb|All]]
    [-log:[Off|Fatal|Error|Warn|Info|Debug|Verbose|All]]
    [-service[:byname]]
    [-servicestarttimeout:<minutes+seconds e.g. 1m23s>
    [-communicationtimeout:<integer, e.g. 10000>
    [-threshold:<max count>]
    [-enableperformancecounters]
    [-skipautoprops]
    [-oldStyle]
or
    -?
or
    -version

For further information on the command line please visit the wiki
    https://github.com/OpenCover/opencover/wiki/Usage

Filters:
    Filters are used to include and exclude assemblies and types in the
    profiler coverage; see the Usage guide. If no other filters are supplied
    via the -filter option then a default inclusive all filter +[*]* is
    applied.
Logging:
    Logging is based on log4net logging levels and appenders - defaulting
    to a ColouredConsoleAppender and INFO log level.
Notes:
    Enclose arguments in quotes "" when spaces are required see -targetargs.

Answer 1:

这看起来像废话

"-targetargs:C:\Test\src\Example.Tests\bin\Debug\example.Tests.dl -filter:"+[Unit]*" 

这样的事情应该更好地工作

"-targetargs:C:\Test\src\Example.Tests\bin\Debug\example.Tests.dll" -filter:"+[*Unit]*" 

我建议你去尝试的批处理文件的PowerShell intstead

下面是示例脚本: https://github.com/rpokrovskij/opencover4vs.ps1

把它放到解决方案文件夹,修改第一行,我希望它会为你工作,而无需额外的变化。



文章来源: Unexpected token '' at position 3 in selection expression