Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
738 views
in Technique[技术] by (71.8m points)

visual studio 2015 - Running unit tests in TFS/VSO Build vNext using xUnit adapter

I am trying to run our xUnit tests using the xUnit test adapter in Visual Studio Online's Build vNext platform.

As stipulated in this article, we need to provide a custom test adapter path pointing to xunit.runner.visualstudio.testadapter.dll.

But this package is restored by NuGet to a global packages folder, namely C:Users{user}.dnxpackages?

How am I to reference this folder in the build step?

VSO vNext Build Test Step

We are using VS 2015 and DNX projects.

EDIT:

I even tried pointing to the package path DLL directly:

C:Usersuildagent.dnxpackagesxunit.runner.visualstudio2.1.0-beta4-build1109uild\_common

It still did not seem to use the adapter:

Executing C:Program Files (x86)Microsoft Visual Studio 14.0Common7IDECommonExtensionsMicrosoftTestWindowvstest.console.exe "C:a8ac4a4f6RootartifactsinMyProject.UnitTest
eleasednx451TransitApi.UnitTest.dll"  /TestAdapterPath:C:Usersuildguest.dnxpackagesxunit.runner.visualstudio2.1.0-beta4-build1109uild\_common /UseVsixExtensions:true /logger:trx
Microsoft (R) Test Execution Command Line Tool Version 14.0.23107.0
Copyright (c) Microsoft Corporation.  All rights reserved.
Starting test execution, please wait...
Warning: No test is available in C:a8ac4a4f6RootartifactsinMyProject.UnitTest
eleasednx451TransitApi.UnitTest.dll. Make sure that installed test discoverers & executors, platform & framework version settings are appropriate and try again.
No results found to publish.

The project.json, if relevant:

"dependencies": {
  "xunit": "2.1.0-beta4-build3109",
  "xunit.runner.dnx": "2.1.0-beta4-build134",
  "xunit.runner.visualstudio": "2.1.0-beta4-build1109"
},

"commands": {
  "test": "xunit.runner.dnx"
},

"frameworks": {
  "dnx451": { }
}
See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

Make a global.json file and put the following into it:

{
  "packages": "packages"
}

That will force your dnu restore to put the packages into .packages, which will hopefully solve the problem. Just specify the test adapter path as $(Build.SourcesDirectory)packages -- you may have to specify the full assembly name, I'm not sure off the top of my head.


Update: I took the sample "HelloMvc" application and got it to build with xUnit tests without a global.json. Here's my build definition:

{
  "build": [
    {
      "enabled": true,
      "continueOnError": false,
      "alwaysRun": false,
      "displayName": "Restore packages",
      "task": {
        "id": "d9bafed4-0b18-4f58-968d-86655b4d2ce9",
        "versionSpec": "*"
      },
      "inputs": {
        "filename": "$(DNXPath)\dnu.cmd",
        "arguments": "restore",
        "workingFolder": "",
        "failOnStandardError": "false"
      }
    },
    {
      "enabled": true,
      "continueOnError": false,
      "alwaysRun": false,
      "displayName": "Run tests",
      "task": {
        "id": "d9bafed4-0b18-4f58-968d-86655b4d2ce9",
        "versionSpec": "*"
      },
      "inputs": {
        "filename": "$(DNXPath)\dnx.exe",
        "arguments": "test",
        "workingFolder": "",
        "failOnStandardError": "false"
      }
    },
    {
      "enabled": true,
      "continueOnError": false,
      "alwaysRun": false,
      "displayName": "Build NuGet package",
      "task": {
        "id": "d9bafed4-0b18-4f58-968d-86655b4d2ce9",
        "versionSpec": "*"
      },
      "inputs": {
        "filename": "$(DNXPath)\dnu.cmd",
        "arguments": "publish",
        "workingFolder": "",
        "failOnStandardError": "false"
      }
    },
    {
      "enabled": true,
      "continueOnError": false,
      "alwaysRun": false,
      "displayName": "Publish Artifact: drop",
      "task": {
        "id": "1d341bb0-2106-458c-8422-d00bcea6512a",
        "versionSpec": "*"
      },
      "inputs": {
        "CopyRoot": "",
        "Contents": "**\output\*",
        "ArtifactName": "drop",
        "ArtifactType": "FilePath",
        "TargetPath": "\\ic-tfs-fs-01\TFSBuilds\$(Build.DefinitionName)\$(Build.BuildNumber)"
      }
    }
  ],
  "options": [
    {
      "enabled": false,
      "definition": {
        "id": "7c555368-ca64-4199-add6-9ebaf0b0137d"
      },
      "inputs": {
        "multipliers": "[]",
        "parallel": "false",
        "continueOnError": "true"
      }
    }
  ],
  "variables": {
    "BuildConfiguration": {
      "value": "debug",
      "allowOverride": true
    },
    "BuildPlatform": {
      "value": "any cpu",
      "allowOverride": true
    },
    "DNXPath": {
      "value": "C:\Users\tfs-build\.dnx\runtimes\dnx-clr-win-x86.1.0.0-beta7-12335\bin"
    }
  },
  "retentionRules": [
    {
      "branches": [
        "+refs/heads/*"
      ],
      "daysToKeep": 10,
      "deleteBuildRecord": true
    }
  ],
  "_links": {
    "self": {
      "href": "http://ic-tfs-at-01:8080/tfs/InCycleEventsCollection/b3284707-3d86-4bc7-b321-b22aee80daca/_apis/build/Definitions/22"
    },
    "web": {
      "href": "http://ic-tfs-at-01:8080/tfs/_permalink/_build/index?collectionId=0ea6f8c1-f923-47f0-b59a-af6d452d8f7f&projectId=b3284707-3d86-4bc7-b321-b22aee80daca&definitionId=22"
    }
  },
  "buildNumberFormat": "$(date:yyyyMMdd)$(rev:.r)",
  "createdDate": "2015-08-12T15:34:17.887Z",
  "jobAuthorizationScope": 1,
  "jobTimeoutInMinutes": 60,
  "repository": {
    "id": "ee7584f9-ba25-4535-9b5e-5038ec6a39c7",
    "type": "TfsGit",
    "name": "AspNet5",
    "url": "http://ic-tfs-at-01:8080/tfs/InCycleEventsCollection/BTE2015/_git/AspNet5",
    "defaultBranch": "refs/heads/master",
    "clean": "false",
    "checkoutSubmodules": true
  },
  "quality": 1,
  "authoredBy": {
    "id": "7f2b1ec7-224f-41de-b679-17e6ef28ce35",
    "displayName": "ICTFS-Admin",
    "uniqueName": "AZURE\ICTFS-Admin",
    "url": "http://ic-tfs-at-01:8080/tfs/InCycleEventsCollection/_apis/Identities/7f2b1ec7-224f-41de-b679-17e6ef28ce35",
    "imageUrl": "http://ic-tfs-at-01:8080/tfs/InCycleEventsCollection/_api/_common/identityImage?id=7f2b1ec7-224f-41de-b679-17e6ef28ce35"
  },
  "queue": {
    "pool": null,
    "id": 1,
    "name": "default"
  },
  "uri": "vstfs:///Build/Definition/22",
  "type": 2,
  "revision": 6,
  "id": 22,
  "name": "ASP .NET 5 app",
  "url": "http://ic-tfs-at-01:8080/tfs/InCycleEventsCollection/b3284707-3d86-4bc7-b321-b22aee80daca/_apis/build/Definitions/22",
  "project": {
    "id": "b3284707-3d86-4bc7-b321-b22aee80daca",
    "name": "BTE2015",
    "url": "http://ic-tfs-at-01:8080/tfs/InCycleEventsCollection/_apis/projects/b3284707-3d86-4bc7-b321-b22aee80daca",
    "state": "wellFormed",
    "revision": 383343

I suspect that the problem is that you're trying to use the Visual Studio test adapter.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

1.4m articles

1.4m replys

5 comments

56.8k users

...