gfoidl / trx2junit

Transforms XML from trx-Testresults to JUnit-Testresults / trx to JUnit XML and the other way round
MIT License
70 stars 17 forks source link

Full path to trx2junit necessary in Circle CI #35

Closed janaagaard75 closed 5 years ago

janaagaard75 commented 5 years ago

This is not really a bug report, but more of an information: I had to write the full path to trx2junit (/root/.dotnet/tools/trx2junit) to get it to work in Circle CI.

Would it be worth mentioning this in the readme? It might also be nice to add a bit more info about configuring Circle CI. Here are the steps related to the tests in my config.yml.

version: 2
jobs:
  build_and_deploy:
    docker:
      - image: microsoft/dotnet:2.2-sdk

      # ...

      - run:
          name: Run tests
          command: |
            dotnet test --logger trx --results-directory "..\TestResults"

      # ...

      - run:
          name: Install TRX 2 JUnit converter
          command: |
            export PATH="$PATH:/root/.dotnet/tools"
            dotnet tool install -g trx2junit
          when: always

      - run:
          name: Convert TRX test results to JUnit format
          command: |
            /root/.dotnet/tools/trx2junit TestResults/*.trx
          when: always

      - store_test_results:
          path: TestResults
gfoidl commented 5 years ago

had to write the full path to trx2junit (/root/.dotnet/tools/trx2junit) to get it to work in Circle CI.

With each run you use a new bash-environment, so the export is "useless". See Setting an Environment Variable in a Shell Command, and that's why https://github.com/gfoidl/trx2junit/blob/55e34d7976208561d965406543ee9b5e7c1d0102/.circleci/config.yml#L20 is used.

Would it be worth mentioning this in the readme?

I don't think so, as this issue is specific to CircleCI, and there it is documented. If this would be mentioned, some other CI-systems should be added too...

might also be nice to add a bit more info about configuring Circle CI

What about other CI-systems? In general configuration for trx2junit is quite simple:

  1. install the tool dotnet tool install -g trx2junit
  2. export the path -- depending on shell / environment
  3. use the tool

This is actually covered in the ReadMe.

Did I miss your point or what would you add to the ReadMe? Feel free to submit an PR, so we can discuss it over there if you'd like.

janaagaard75 commented 5 years ago

No, no. You didn’t miss anything. This was just a suggestion, but I think your points are very valid.

gfoidl commented 5 years ago

Anyway, thanks for the suggestion 👍 and I hope you can setup CircleCI in a correct way.

capalmeida commented 2 years ago

I'm trying to setup the trx2junit in circleci but can't get it to work, so far my relevant code is:

 # ...

- run:
      name: "Run Application Tests"
      command: dotnet test --no-build --logger "trx" --results-directory tests/output
  - run:
      name: "Collect Test Results"
      when: always
      command: |
        dotnet tool install -g trx2junit
        echo 'export PATH="$PATH:/root/.dotnet/tools"' >> "$BASH_ENV"
        trx2junit tests/output/*.trx --output tests/TestResults

Error from circleci:

  # ...
  trx2junit : The term 'trx2junit' is not recognized as the name of a cmdlet, function, script file, or operable 
  program. Check the spelling of the name, or if a path was included, verify that the path is correct and try  again.
  At line:3 char:1

Any ideas on how I can overcome this? Also this started as we're setting up .NET 6 in our build pipelines, until then the following code worked without a problem:

  - run:
      name: "Collect Test Results"
      when: always
      command: |
        dotnet tool install -g trx2junit
        trx2junit tests/output/*.trx --output tests/TestResults
gfoidl commented 2 years ago

@capalmeida https://github.com/gfoidl/trx2junit/issues/35#issuecomment-1076215784 is the same as https://github.com/gfoidl/trx2junit/issues/96? So we can continue on #96?

capalmeida commented 2 years ago

Yes!