question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Unable to test non-Core code on Linux

See original GitHub issue

(Apologies if this is the wrong repo for this; it’s not clear to me whether this is xUnit-specific or the expected behaviour when testing on Linux.)

Background

I have projects which don’t target core yet, but I still want to test on Travis. They work fine on RC1 (with dnx test and the old xUnit setup) and work fine with an updated project.json on Windows, but fail to run tests on Linux.

It’s not clear whether the non-core runtimes/frameworks are expected to work on non-Windows platforms. Using dotnet run works fine for a console app with a TFM of net451, so it’s clearly got some knowledge… but dotnet test fails.

Similar issues: dotnet/sdk#4833, dotnet/sdk#5172.

Steps to reproduce

Create xUnit test project with a framework of net451, and run dotnet restore, dotnet build, dotnet test.

Sample project.json:

{
  "dependencies": {
    "xunit": "2.1.0",
    "dotnet-test-xunit": "1.0.0-rc2-build10015",
  },

  "testRunner": "xunit",

  "frameworks": {
    "net451": { }
  }
}

Sample C#:

using Xunit;

public class Test
{
    [Fact] public void Foo() {}
}

Expected behavior

Tests run (using Mono).

Actual behavior

Restore and build both work, but test fails:

dotnet-test Error: 0 : Microsoft.DotNet.Cli.Utils.CommandUnknownException: No executable found matching command "dotnet-test-xunit"  
  at Microsoft.DotNet.Cli.Utils.ProjectDependenciesCommandFactory.FindProjectDependencyCommands(String commandName, IEnumerable`1 commandArgs, String configuration, NuGetFramework framework, String outputPath, String buildBasePath, String projectDirectory)  
  at Microsoft.DotNet.Cli.Utils.ProjectDependenciesCommandFactory.Create(String commandName, IEnumerable`1 args, NuGetFramework framework, String configuration)  
  at Microsoft.DotNet.Tools.Test.ConsoleTestRunner.DoRunTests(ProjectContext projectContext, DotnetTestParams dotnetTestParams)  
  at Microsoft.DotNet.Tools.Test.TestCommand.DoRun(String[] args)

Environment data

dotnet --info output:

.NET Command Line Tools (1.0.0-preview1-002702)

Product Information:
 Version:     1.0.0-preview1-002702
 Commit Sha:  6cde21225e

Runtime Environment:
 OS Name:     ubuntu
 OS Version:  15.10
 OS Platform: Linux
 RID:         ubuntu.15.10-x6

Issue Analytics

  • State:open
  • Created 7 years ago
  • Reactions:1
  • Comments:32 (6 by maintainers)

github_iconTop GitHub Comments

4reactions
RehanSaeedcommented, Oct 10, 2016

I has been some time since this issue was raised. Is the above nasty workaround the only real solution at this point? The alternative being to wait for a preview3 tooling release?

3reactions
borgdylancommented, Jul 3, 2016

If a net451 exe exists in the package, you will have to do a mono bootstrap script.

#!/usr/bin/env bash

SOURCE="${BASH_SOURCE[0]}"
while [ -h "$SOURCE" ]; do # resolve $SOURCE until the file is no longer a symlink
  DIR="$( cd -P "$( dirname "$SOURCE" )" && pwd )"
  SOURCE="$(readlink "$SOURCE")"
  [[ $SOURCE != /* ]] && SOURCE="$DIR/$SOURCE" # if $SOURCE was a relative symlink, we need to resolve it relative to the path where the symlink file was located
done
DIR="$( cd -P "$( dirname "$SOURCE" )" && pwd )"

exec mono "$DIR/dotnet-test-xunit.exe" "$@"
Read more comments on GitHub >

github_iconTop Results From Across the Web

Unable to test non-Core code on Linux #6128
Tests run (using Mono). Actual behavior. Restore and build both work, but test fails: dotnet-test Error: 0 : Microsoft.DotNet.Cli ...
Read more >
Diagnosing a Linux-only unit test failure
Step 1: Check there's really a problem · Step 2: Reproduce locally · Step 3: Remove irrelevant test code · Step 4: Remove...
Read more >
Core dumped, but core file is not in the current directory?
While running a C program, It says "(core dumped)" but I can't see any files under the current path. I have set and...
Read more >
9 QA Error and Warning Messages
This test fails if any binaries do not match the type since there would be an incompatibility. The test could indicate that the...
Read more >
Visual Studio 2019 version 16.9.1 resulted in custom ...
After i upgrade the visuals studio 2019 to 16.9.1,I am not able to see the custom scaffolders in the “Add New Scaffolded item”...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found