My colleagues (developers) have created a bunch of unit tests, for a project.
And I have been assigned as a test manager on it, and are using Testrail to build the test suites and cases for the manuel testing.
I would like to gather both the manuel and unit test, test result in testrail.
The unit tests are made with Nunit, wich gives me certain options to pull out the result of each unit test via the [Teardown] method, basically I put in this line:
TestRailAPIPost(String.Format("{0}", TestContext.CurrentContext.Result.Status), TestContext.CurrentContext.Test.FullName, 189, 6668);
The method looks like this:
public void TestRailAPIPost(string status, string comment, int testrun, int testcase)
{
Gurock.TestRail.APIClient client = APIClientCall();
int sta_id;
if (status == "Passed") { sta_id = 1; } else sta_id = 5;
var data = new Dictionary<string, object> { //1 = Passed, 2 = Blocked, 4 = Retest, 5 = Failed { "status_id", sta_id }, { "comment", comment } };
**JObject p = (JObject)client.SendPost("add_result_for_case/" + testrun + "/" + testcase, data);** }
And this works.
The next step in my plan is to make the test run on the fly by using the “add_run” command, and then somehow get the result back so I can add that in the above JObject call.
This is not working for me.
First of I have a hard time figuring out if I’m using the correct project id. Am I correct in assuming that I get it from the URL:
¨
Project id = 17 ?
If thats the case something else is wrong when I try and write the following:
JObject c = (JObject)client.SendPost(“add_run/” + 17, “blabla”);
I get the following error in Nunit:
TearDown : Gurock.TestRail.APIException : TestRail API returned HTTP 400 (“Invalid or incomplete JSON string in API request.”)
According to your documentation Error 400 is “Invalid or unknown project”
I know that the data needs to contain more than “blabla” but I need to make sure that I call the correct project before I create the data