allankp / pytest-testrail

pytest plugin for integration with TestRail, for creating testruns and updating results
MIT License
95 stars 125 forks source link

How to add custom output to test result comment #45

Closed tlvu closed 4 years ago

tlvu commented 6 years ago

Hi,

This is not a bug, just a question. Not sure how to reach you the author so kindly forgive me if you have a preferred channel for question.

In both passed and failed case, I'd like to be able to add custom output to the result comment. The testrail API http://docs.gurock.com/testrail-api2/reference-results#add_result also allows for version, elapsed, defects, assignedto_id as well.

For all these extra fields that can be set per result, how do I set them?

Thanks.

apallier commented 6 years ago

Hi @tlvu, you can custom some outputs but maybe not the way you want:

tlvu commented 6 years ago

Hi @apallier,

Thanks for the quick response.

Indeed, elapsed and version are working as expected.

For comment field, in my test I have "assert \<condition>, \<text when failed>". I wanted for "\<text when failed>" to show on testrail comment field only, but I get the full test case and pseudo stack-trace which is less useful to non coder reader.

When the test passed, all I get no comment field at all. Is there a way to customize this? Always able to add something to the comment field regardless of the pass/fail status?

Basically is there a way to override the automatic comment field provided by pytest? The use-case is to provide concise and meaningful comment field to coder and non-coder reader.

apallier commented 6 years ago

@tlvu Sorry but what you need doesn't exist now...

DamienBth commented 5 years ago

Hello ! TLDR: :+1: I am also very interested about this feature. Or by a workaround if possible ?

I am doing interop tests between multiple products, each test run matching a combination of different versions of the products, so it would be great to have the version of these products in the testrail comment section: Test C1000 (Day D): Product1 v2.0.1 - Product2 v1.1.3 - Product3 v3.2 Test C1000 (D+1): Product1 v2.0.2 - Product2 v1.1.3 - Product3 v3.2 Test C1000 (D+2): Product1 v2.0.2 - Product2 v1.1.4 - Product3 v3.3 ... Moreover, I agree with @tlvu, in my company testrail is for non-coder, they clearly don't need the backtrace in the comment, it would be really great to override it. Is there a way to do it with some tricks ? Like getting the plugin instance and modify some value before the end of the test ?

Thank you :)

eparubrub-view commented 5 years ago

Hello, I am also very interested in this feature, has anyone found a workaround for this?

allankp commented 4 years ago

Issue appears to be resolved now

pnguyenV commented 4 years ago

Hello, "--tc-custom-comment" applies to all test cases as a default? and not customized for one selected case like how it is with pytest.fail()? I like to add a custom message for a pass case but all the pass cases.

voloxastik commented 4 years ago

Hi @allankp! Are there plans to add a custom comment from each test? For example, pass the values ​​of some parameters to the test (for example, from a parameterized parameter)?

MischaZihler commented 4 years ago

@PeterNgTr with your addition "add the ability to extend the comment of test case #105" is it now possible to add a comment to a pytest case, when it's passed? I want to publish the results even if the test has passed. If so, how can you achieve that?

This doesn't work: @pytestrail.case('C6095') def test_reboot(coms): assert True, "custom_comment=yala" assert True, "custom_comment:wret"

kobenguyent commented 4 years ago

@MischaZihler have you checked this? https://github.com/allankp/pytest-testrail#config-for-testrail

MischaZihler commented 4 years ago

@PeterNgTr Yes, i am able to implement everything, but not that it publishes a comment from my pytest into a testrail result, when passed, only when failed. I digged a little bit deeper and it seems that the code takes whatever pytest gives back and with your feature adds the custom comment. Unfortunately this is not what I want because first it only adds information, when it fails and second the custom-comment is generic for the whole run and not for each test (it is fairly possible, that I use it wrong).