Skip to content
This repository has been archived by the owner on May 31, 2019. It is now read-only.

dotnet test with logger trx is not working #211

Closed
schwamster opened this issue Mar 9, 2017 · 7 comments
Closed

dotnet test with logger trx is not working #211

schwamster opened this issue Mar 9, 2017 · 7 comments
Assignees
Labels
closed-external Closed because the issue is external to the project in this repo.

Comments

@schwamster
Copy link

capture

background:
i just switched from project.json to csproj and 1.1.0 to 1.1.1
when changing that i realized that

dotnet test -xml testresult.xml

does not work anymore. I found you can use the parameter --logger for that. So on my windows machine
i ran

dotnet test --logger:trx

and got a testresult

running the same thing within the build image does not work. It does not complain really, but it does not output the testresults. if i use some fantasy logger --logger:something it says it cannot find the logger specified. So it seems that it runs but somehow cannot write the file or something.

I attached a screenshot of the outputs in the console.

Is this a problem with the build image or with the dotnet cli?

@natemcmaster
Copy link
Contributor

Which version of dotnet is in your image? dotnet --info. I'm guessing you have a stale image and need to re-pull. I could not reproduce this with the latest.

image

@schwamster
Copy link
Author

capture

@schwamster
Copy link
Author

removing and re-pulling the image did not help...

@natemcmaster
Copy link
Contributor

Can you share a project and a dockerfile that reproduces this issue? I'm still not able to reproduce using microsoft/aspnetcore-build:latest.

These are my steps:

docker run -it --rm microsoft/aspnetcore-build:latest
mkdir /app && cd /app
dotnet new xunit
dotnet restore
dotnet test --logger:trx

This produces a trx file as expected.

@schwamster
Copy link
Author

running it from scratch as described by you in the prev comment does indeed produce a trx file.
so the problem must be with the project itself - will investigate that further and post an update later

@schwamster
Copy link
Author

schwamster commented Mar 21, 2017

ok, some more info:

after figuring out, that it worked fine with @natemcmaster 's sequence i played around with it a little bit more. and i found out, that i can reproduce the problem if i do it closer to my own example and that is with a volume mount. Important info: Running Docker Toolbox on Win 7!!

docker run -it --rm  -v //c/Users/myuser/myapp:/app microsoft/aspnetcore-build:latest
cd /app
dotnet new xunit
dotnet restore
dotnet test --logger:trx

Now the trx file is not generated. Then i tried to figure out why and started another test:

docker run -it --rm  -v //c/Users/myuser/myapp:/app microsoft/aspnetcore-build:latest
mkdir /app-test && cd /app-test
dotnet new xunit
dotnet restore
dotnet test --logger:trx
cp -R TestResults /app/

That sequence creates the trx file but fails to copy it to the volume:
capture

! This is not a problem when you run docker for windows on win 10, since it seems that the files get renamed somehow. Even though it still is a problem if you rely on the filenames...
win10

The only workaround i have for now is to change how i build my project (no volume mounting of my solution, building in the container then copying the results to a mounted volume AFTER renaming the trx files to something that windows can work with. FYI the problem is the colon int the filename.

if you run dotnet test --logger:trx on windows the filename does not contain colons and uses underscores instead.

Why doesn't the trx logger use the same format on linux?

@natemcmaster
Copy link
Contributor

Glad you figured it out. I'm going to close this as it's not something the docker images can fix. You can workaround by changing the trx filename.
dotnet test "--logger:trx;LogFileName=results.trx".

Can you open an issue on https://github.com/microsoft/vstest to not use semicolons in the trx file by default?

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
closed-external Closed because the issue is external to the project in this repo.
Projects
None yet
Development

No branches or pull requests

2 participants