gurock / trcli

TR CLI (trcli) is a command line tool for interacting with TestRail.
Mozilla Public License 2.0
47 stars 42 forks source link

Field :section_id is not a valid ID - Question #111

Closed iloy1004 closed 1 year ago

iloy1004 commented 1 year ago

Hi, I'm having issue when trying to upload test results from XML to testRail.

The below is the command I used trcli -y -c "trcli-config.yml" parse_junit -f "reports/junit-report.xml"

and this is the config file.

host: https://XXXX.testrail.io/
project: SMOKE TEST
username: XXX@XXXX.com
password: XXXX
title: Cypress Automated Test
file: reports/junit-report.xml
suite_id: 170
auto_creation_response: true

The below is what I've got, and I have no idea what's section id and why it's a problem because it was working well before. Does anyone have any idea? I would appreciate it if anyone could help me.

trcli -y -c "trcli-config.yml" parse_junit -f "reports/junit-report.xml"
Checking project. Done.
Found test cases not matching any TestRail case (count: 1)
Adding missing test cases to the suite.
Adding test cases: 0/1
Error during add_case. Trying to cancel scheduled tasks.

Aborting: add_case. Trying to cancel scheduled tasks.
Adding test cases: 0/1
Field :section_id is not a valid ID.
MattKiazyk commented 1 year ago

I've come to realize that adding a -v onto the call gives you a verbose log that tells you what the actual issue is or at least leads you in the right direction.

iloy1004 commented 1 year ago

I've come to realize that adding a -v onto the call gives you a verbose log that tells you what the actual issue is or at least leads you in the right direction.

Thanks Matt, I've got this details with -v as your suggestion. do you happen to have any idea why api returns 400? URL also seems incorrect as it ended "/add_case/None".

**** Found test cases not matching any TestRail case (count: 1) Adding missing test cases to the suite. Adding test cases: 0/1 **** API Call method: POST url: https://tactio.testrail.io/index.php?/api/v2/add_case/None payload: {'title': 'Dashboard Dashboard Changing groups', 'custom_automation_id': 'Dashboard Changing groups.Dashboard Dashboard Changing groups'} response status code: 400 response body: {'error': 'Field :section_id is not a valid ID.'}

d-rede commented 1 year ago

Hello @iloy1004

Thanks for bringing this to our attention. Can you provide a sample of the report with which we can reproduce the issue?

JonathansDCI commented 1 year ago

I also have this issue @d-rede. This is my first time working with testRailCLI and I was working my way to get the automated creation of test cases creating a proof of concept. I had our Testrail Admin create a new fake Project that has the automation_id as a string on test cases. There are no test cases, runs, etc. on this project. Test-Results.zip

**** API Call method: POST url: https://xxxxxxxx.testrail.net/index.php?/api/v2/add_case/0 payload: {'title': 'Test2', 'custom_automation_id': 'TestProject1.SmokeTests.Test2'} response status code: 400 response body: {'error': 'Field :section_id is not a valid section.'}


Adding test cases: 0/2 Field :section_id is not a valid section.

Testinator-X commented 1 year ago

I also have this issue @d-rede. This is my first time working with testRailCLI and I was working my way to get the automated creation of test cases creating a proof of concept. I had our Testrail Admin create a new fake Project that has the automation_id as a string on test cases. There are no test cases, runs, etc. on this project. Test-Results.zip

**** API Call method: POST url: https://xxxxxxxx.testrail.net/index.php?/api/v2/add_case/0 payload: {'title': 'Test2', 'custom_automation_id': 'TestProject1.SmokeTests.Test2'} response status code: 400 response body: {'error': 'Field :section_id is not a valid section.'}

Adding test cases: 0/2 Field :section_id is not a valid section.

I‘ve checked your import file

<testsuite name="ddm-api-beta.dll" tests="2" skipped="0" failures="1" errors="0" time="1.2098879999999999" timestamp="2023-02-21T18:57:23" hostname="JONATHANS-LT" id="0" package="ddm-api-beta.dll">

The id you provide is id="0" but the id should match a section id you have in your project. I‘m quite sure there is no section with an ID of 0. change the ID to a section that exists in your project and it should work.

I think it’s quite the same problem as described here https://github.com/gurock/trcli/issues/71

d-rede commented 1 year ago

Hey everyone!

Using the id attributes coming from the XML report was in fact undesired behavior and a fix was applied in v1.4.3. The id attributes are no longer being considered for sections and suites.

Note: If you are using a multisuite project, you should use the --suite-id command line option to pass the id of the suite you want your test run created in.

JonathansDCI commented 1 year ago

My test results file was generated by https://github.com/spekt/junit.testlogger. I don't even know what a section id is.

d-rede commented 1 year ago

Hi there @JonathansDCI

Can you install TestRail CLI version 1.4.3 and try importing your test results again? The issue with the IDs in the report should no longer occur.

JonathansDCI commented 1 year ago

IDK how to install a specific version, I don’t see any documentation except pip install trcli and that gives me version 1.4.1

From: Diogo Rede @.> Sent: Wednesday, February 22, 2023 12:12 PM To: gurock/trcli @.> Cc: Jonathan Souza @.>; Mention @.> Subject: Re: [gurock/trcli] Field :section_id is not a valid ID - Question (Issue #111)

Hi there @JonathansDCIhttps://github.com/JonathansDCI

Can you install TestRail CLI version 1.4.3 and try importing your test results again? The issue with the IDs in the report should no longer occur.

— Reply to this email directly, view it on GitHubhttps://github.com/gurock/trcli/issues/111#issuecomment-1440736652, or unsubscribehttps://github.com/notifications/unsubscribe-auth/A6BN33DRKQRK2DQ3V4AQJD3WYZXIRANCNFSM6AAAAAATQEUW5I. You are receiving this because you were mentioned.Message ID: @.**@.>>

Testinator-X commented 1 year ago

C:\Path\To\Your\Python\Directory\python.exe -m pip install --upgrade trcli

@d-rede this should be added to readme.

JonathansDCI commented 1 year ago

Works: dotnet test --no-build --configuration Release --test-adapter-path:. --logger:"junit;LogFilePath=${REPORTS_PATH}/TestReport.xml" trcli -y -c "trcli-config.yml" parse_junit -f "${REPORTS_PATH}/TestReport.xml"

From: Testinator-X @.> Sent: Wednesday, February 22, 2023 2:37 PM To: gurock/trcli @.> Cc: Jonathan Souza @.>; Mention @.> Subject: Re: [gurock/trcli] Field :section_id is not a valid ID - Question (Issue #111)

C:\Path\To\Your\Python\Directory\python.exe -m pip install --upgrade trcli

— Reply to this email directly, view it on GitHubhttps://github.com/gurock/trcli/issues/111#issuecomment-1440920377, or unsubscribehttps://github.com/notifications/unsubscribe-auth/A6BN33GPJXVY6GFOY3LUZELWY2IHPANCNFSM6AAAAAATQEUW5I. You are receiving this because you were mentioned.Message ID: @.**@.>>

Testinator-X commented 1 year ago

Lucky you! My problem from https://github.com/gurock/trcli/issues/71 has not been fixed, although the ticket has been closed. (Or I still don't know how to work around the problem via command line. )

JonathansDCI commented 1 year ago

Reading your bug #71 there is two slightly different issues, your error is complaining that you have a string value vs an int for id="foobar suite". My bug, which they fixed, is that https://github.com/spekt/junit.testlogger is outputting that ID="0" but I don't use that field at all (at least in a bare bones demo project). When I generate a junit file through the nunit console and transform it like the Sample Project, the id doesn't get generated in the junit file.

I suspect that although, there was a code change to ignore Id in the parsing, I suspect that there is some schema/transform/validation thingy still active before ID is even parsed, thus your id = string is still a problem,

iloy1004 commented 1 year ago

Hello @JonathansDCI and @d-rede , thank you for your comments. I apologize for not checking the thread for a while.

I resolved the issue by deleting some test cases in TestRail that I haven't developed scripts for in Cypress. Although I'm not entirely sure if this is the correct solution, the same command to send results to TestRail is now working fine after removing the extra test cases.

Previously, I added a few extra test cases to serve as guidelines when creating scripts, similar to blueprints. This resulted in the test suite having a greater number of test cases than what I actually implemented in the code.

It's still mystery for me why the error said section ID in that situation.