Forum Discussion
It's not a RESTful API. So you need to use the code they provide for binding to various languages and integrate it into TC using the CLR Bridge functionality. Which allows you to use external libraries.
The previous poster used the .NET bindings.
So start reading here: https://support.smartbear.com/testcomplete/docs/testing-with/advanced/using-external-functions/calling-from-dotnet-assemblies.html
Which is what you'll need to use: http://docs.gurock.com/testrail-api2/bindings-dotnet
Now, I do notice that TestRail refer to that as V2 of their API. I have no idea if the above script was written using these bindings, or ones from an older version.
But above all, you need to understand how to use external libraries. Once you understand that, then you can start worrying about how you create and use one for TestRail. (And you need someone who knows their way around Visual Studio and .NET to make all this work.)
Apparently there's an error when parsing the request.
So what I did is compiling the testrail integration with donNET Gurock.TestRail including Json90 library.
Then added the resulting dlls to the CLR Bridge using 64-bits architecture/appartment model = 'Does not matter' (as it seems to be the right thing to do although I'm not sure)
Then calling the function where parameters are correct and meaning (testRun, testCaseNumber):
function testUpdateTestRail() {
testrail.retestCase(13, 3486);
}
The error is what you see in the image.... Any clues/suggestions?
I guess the real question would be if CLR has been added correctly, which I assume yes as I can see the dotNET routines when typing and why isn't parsing Json correctly and how to debug it.
Thank you
- Colin_McCrae8 years agoCommunity Hero
CLR Bridge (which I've only used once) seems to be working fine. The error is coming from the TestRail method.
Looks like it simply doesn't like one of the characters in your file path. (Hence the "unexpected character" error. The actual TestRail API isn't one I'm familiar with ...) Without knowing which API endpoint you're hitting, and the JSON you're sending it, can't be certain what it doesn't like. But it looks like a file path? And you have back, rather than forward slashes in there? In which case, you may need to double them up as per: http://stackoverflow.com/questions/24828873/sending-a-filepath-in-json-string-to-php-codeigniter
Or switch it to using forward slashes.
Have you tried putting the JSON into something like: http://jsonlint.com/
... to check it's valid?
- leandropoblet8 years agoFrequent ContributorHi Colin,
Thanks again for taking time to reply.
There's no paths involved here. If you look the function I'm calling:
function testUpdateTestRail() {
testrail.retestCase(13, 3486);
}
has only two parameters on it. Test run and Test case number both hardcoded integers just for testing the connection between TestComplete and TestRail.
If you follow the scripts posted by schef you'll see there's no file paths either.
On the other hand... how do I get to see the Json being sent.... no idea and it'd be great to know even for future debugging.
Cheers,
Leandro- Colin_McCrae8 years agoCommunity Hero
Sorry. My mistake in my previous post.
You are quite right. It's the JSON parser that's throwing the error.
I'm afraid I don't know why. The TestRail method must be passing something into it, which it doesn't like. (Or the DLL is bugged I guess?) Not sure how you debug it to allow you to actually inspect the JSON. Don't know what options are available to you here. I doubt you can step into external DLL code via the TC debugger?
Having never used any of this stuff, and not being an expert in JSON parsing, I'll need to leave this one for someone who knows the area better.
Looking at it, this is the TestRail method it ends up in:
http://docs.gurock.com/testrail-api2/reference-results#add_result_for_case
You only pass it a Test ID and a Run ID. So it must be interpreting something in the TC run to generate it's status to hand off to the API. As that's the point of the call. To update the test result/status.
The request should be generated to look the same as:
http://docs.gurock.com/testrail-api2/reference-results#add_result
... which can accept various additional fields. But the script looks like it only adds a status. (And any additional stuff you put in the call .... which is nothing in this case)
** BRAINWAVE! **
Hang on. This may be the same as TFS. In TFS-Land (I wrote my own extensions to do much the same as you're doing with TestRail) a Test Case moves from run to run. The Case ID stays the same, but the Test ID changes as you move it on from run to run.
Your method has to take in a Run ID and Case ID.
You mention passing it a Test ID. I wonder if you need to use one of the other methods (ie. runIdAndCaseIdFromTestId ) to get the Case ID and then use the ID it passed back to update the actual result?
Maybe give that a try?
Related Content
- 2 years agoragul