dotnet / dotnet/sdk

dotnet test may silently skip tests if .nuget folder is missing

Open
#43,442 7 comments 1 reaction 0 assignees View on GitHub
Area-dotnet test Area-dotnet test (VSTest)
Dominant language
C#
Stars
3.2k
Forks
1.3k
PR merge metrics
PR metrics pending

Description

### Description

I am building a project and I have two pipeline jobs:
1. build
2. test

In build, I am building the project with:
```
dotnet build -c Release --packages .nuget
```
Then I transfer the build output of to the test job via glob expression using `./**/obj/` and `./**/bin/`.

Then in the test job I run `dotnet test --no-build -c Release`. If I forget to transfer the `.nuget` folder from the build context to the test context, then the tests will silently fail but there is no indication of the error and the test command has a 0 exit code indicating success.

I observe that `dotnet test` does not accept a `--packages .nuget` argument and the `/obj/` folder implicitly holds information about the expected location of the `.nuget` package folder that was used during build. So I guess this information should be validated during the `dotnet test` command and we should fail with an

### Reproduction Steps

1. Start with a project that has an application project and a test project
2. Create two separate steps (build and test) for example in a pipeline or a local workspace.
3. Build the project in the first step using `dotnet build -c Release --packages .nuget`
4. Transfer the build output to the second step using globs to select the build output, i.e. ./**/bin/` and `./**/obj/` (but do not copy .nuget.
5. Run tests via: `dotnet test --no-build -c Release`

### Expected behavior

Tests should fail with a non-zero exit code and should print an error message that inform about the missing `.nuget` folder.

### Actual behavior

Exit code is 0 (on Linux) but no tests are being executed.

### Regression?

_No response_

### Known Workarounds

_No response_

### Configuration

_No response_

### Other information

_No response_

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.