-
Notifications
You must be signed in to change notification settings - Fork 5.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Unit testing example does not work in docker #828
Comments
@alexellis Thanks for writing the issue, and providing a link to your project. I think you are seeing the error because your tests are in the 'test' directory, and not it in a subdirectory of 'test'. Can you move that project into a sub-directory (e.g. 'test/EngineTests') and let us know if it works? We can update the article to make that more clear. Thanks. |
@BillWagner I'm afraid that didn't solve the problem. This works on my Mac, but not within Docker with either of the official images. Here are more details. This is my resulting structure: (You can clone it and try it - if you're on Mac or Windows 10 there is a 1-click install for Docker that runs without VirtualBox)
Same issue, works on Mac locally, but not in Docker image.
Whatever was installed on my Mac
Preview 1 on Docker:
Preview 2 on Docker
What is interesting is that the RateCalc.App application compiles without warnings. Can you also speak to the odd part of the project.json file.. ?
|
Thanks for doing that research. Let me do a bit of research, and I'll get back to you. |
@alexellis in your Dockerfile, could you test out what happens when you change the WORKDIR to point to the root folder, where the Actually, come to think of it, you could run |
I think @alexellis is missing the |
@jeremymeng the Dockerfile in the repo shows that global.json is being added. |
It is now working inside Docker, but does a complete restore every build. Is there a way of changing the instruction order to take advantage of the step caching? I.e. in nodejs with npm you can restore before adding any code. |
@blackdwarf @jeremymeng can you help with @alexellis's last question? |
@glennc might have some ideas for this scenario (dotnet restore caching in Docker). |
@spboyer can you take a look at this one? |
@alexellis when you say that it is doing the restore every time, you are stating that each time you build the image? The
the build is not downloading these files from Nuget, but copying them from the local cache that exists within the image. Within your Dockerfile, you are adding the application files to the image each time it is built.
In my test, I never called Given the amount of time to run this, Time elapsed 00:00:01.1501594; I would say that the cache being used within the Docker image is acceptable given the scenario of not ever having the dotnet resources on the local machine. The alternative way to accomplish this would be to run the cc:/ @glennc @SteveLasker |
I'm sure it was not taking 1 second (a lot longer). Let me try to reproduce the issue - I guess this was raised 3 months ago maybe things have changed. |
@alexellis - 3 months ago I don't believe we were loading the Nuget cache in the base image, there has been some improvements there. |
@spboyer so please could you clone the repo - do your initial build and then just edit the name of one of the tests in the CsvParserTests.cs file? $ time docker build -t market-rates .
real 0m41.416s
user 0m0.031s
sys 0m0.032s |
Output from editing a unit test name:
|
@alexellis - see the results below. I want to say that given the scenario of restoring and building the application within the application; its pretty good. The Nuget cache is within the base container. First run - no rates image
Second run - after change
|
@BillWagner It looks like we could close this and replace with an update for 2.0 issue. Am I right? |
I recently posted an example for Unit Testing with Multistage dockerfiles: |
I think we can close this. The articles have been updated. |
Issue Title
With this article:
https://github.com/dotnet/core-docs/blob/master/docs/core/testing/unit-testing-with-dotnet-test.md
General
I was able to set up a unit test project and have this restored/running on my Mac but when it came to using the Docker image for Preview 1 or 2 it failed.
The code is available here:
https://github.com/alexellis/dncore-market-rates
I am a bit confused about these two lines in the unit test project:
The other projects created are using dncore 5.0 - does this mean we need Mono or a full .NET runtime in order to use xunit?
@BillWagner / @ Steve Smith
I've also provided a Dockerfile.
The text was updated successfully, but these errors were encountered: