2

I'm using Docker Swarm on Linux to host TeamCity. In my instance I'm running integration tests via a docker-compose file, using xUnit.

I'm really struggling with the steps I need to use to get Tests tab to appear when I'm running my tests (which in turn will stop my builds if there is a failing xUnit test). I was able to get this to work fine with TeamCity 2017.1.2 but it refuses to work in TeamCity 2017.2.4.

I've added "ENV TEAMCITY_PROJECT_NAME=fake" to my Docker file as per the example (which I think is all I need to do).

How do I get the Tests tab back, and get my builds to stop when a test breaks please?!

Any assistance gratefully received - I'm tearing my hair out over this one!

Steve_333
  • 133
  • 10

2 Answers2

3

Thanks. I did manage to get it working in the end.

The end of my Dockerfile is as follows:

FROM microsoft/dotnet:2-sdk

...
...

# Set the flag to tell TeamCity that these are unit tests:
ENV TEAMCITY_PROJECT_NAME = ${TEAMCITY_PROJECT_NAME}

# Run the tests:
ENTRYPOINT ["dotnet", "test", "--verbosity=normal"]

I also added this to the docker-compose file I'm using:

version: '3.6'
  ...
  ...
  steve.core.tests:
    image: steve.core.tests:tests
      build:
        context: .
        dockerfile: Dockerfile-run-tests
      environment:
        - TEAMCITY_PROJECT_NAME

Might be belt and braces but it seems to work.

I'm using TeamCity server version 2018.1.1 with the same agent version. I've installed Docker Compose v1.22.0 into my TeamCity agent.

Now I just need to work out how I can fail my builds when the test coverage isn't high enough. See here for my next question: Breaking the build in TeamCity if .NET Core unit tests running under Docker have code-coverage less than 90%

Steve_333
  • 133
  • 10
0

I ran into this problem as well. Nick Adcock posted a nice solution at https://devblog.bango.com/2017/10/13/build-in-docker-test-with-net-core-report-to-teamcity/

He supplies an updated version of the microsoft/dotnet:2.0-sdk image that outputs test results in a format that can be read, used and presented by TeamCity. I'm using it with TeamCity 2017.2.4 and it seems to work fine. It didn't count my tests correctly, but at least now I have easily visible test outcomes.

Hope this was able to help you.

1MuddyDog
  • 21
  • 2