public void TestMethod1() { TestStuffLib.TestStuffTransaction TST = new TestStuffTransaction(TestStuffLib.TestStuffLib.LoginUser.SQAAUTO); TestStuffLib.TestStuffLib TSL = new TestStuffLib.TestStuffLib(); }
public TestStuffTransaction SubmitTestTransaction(TestStuffTransaction _TestStuffTransaction) { this.CurrentTestStuffTransaction = _TestStuffTransaction; return _TestStuffTransaction; }
internal bool SendTestStuffTestStepResult(TestStuffTransaction _TestStuffTransaction) { bool rc = false; // set Web API connectivity parameters // replace email, password and serviceX with your account details string s_username = "******"; string s_password = "******"; string s_url = "https://service2.testuff.com/api/v0/run/"; // set test scenario parameters string s_test_id = "d5e94a3a0eb0970859f2642c9f4786d5";// "2 Automation Smoke tests"; string s_status = "FAILED"; string s_steps_failed = "1,3"; string s_steps_passed = "2"; string s_steps_maybe = "3"; string s_comment = "Automated comment"; string branch_name = "Automated branch1"; string lab_name = "AutomatedLab1"; string run_configuration = "Automated config "; string version = "Automated version1"; StringBuilder s_JSON_builder = new StringBuilder(); s_JSON_builder.Append("{ "); s_JSON_builder.Append("\"" + "test_id" + "\": " + "\"" + s_test_id + "\""); s_JSON_builder.Append(",\"" + "status" + "\": " + "\"" + s_status + "\""); s_JSON_builder.Append(",\"" + "steps_failed" + "\": " + "\"" + s_steps_failed + "\""); s_JSON_builder.Append(",\"" + "steps_passed" + "\": " + "\"" + s_steps_passed + "\""); //s_JSON_builder.Append(",\"" + "steps_maybe" + "\": " + "\"" + s_steps_maybe + "\""); //s_JSON_builder.Append(",\"" + "branch_name" + "\": " + "\"" + branch_name + "\""); s_JSON_builder.Append(",\"" + "lab_name" + "\": " + "\"" + lab_name + "\""); s_JSON_builder.Append(",\"" + "run_configuration" + "\": " + "\"" + run_configuration + "\""); s_JSON_builder.Append(",\"" + "version" + "\": " + "\"" + version + "\""); s_JSON_builder.Append(",\"" + "comment" + "\": " + "\"" + s_comment + "\""); s_JSON_builder.Append("}"); //s_JSON_builder.Append("{\"test_id\":\"d5e94a3a0eb0970859f2642c9f4786d\",\"status\":\"failed\",\"steps_failed\":\"2\",\"comment\":\"automated test comment\"}"); string s_JSON = s_JSON_builder.ToString(); string res = "";// rest.Content; try { // System.Net.HttpWebRequest adds the header 'HTTP header "Expect: 100-Continue"' to every request by default System.Net.ServicePointManager.Expect100Continue = false; HttpWebRequest req = (HttpWebRequest)WebRequest.Create(s_url); req.Credentials = new NetworkCredential(s_username, s_password); //This line ensures the request is processed through Basic Authentication req.ContentType = "application/json"; req.Method = "POST"; //req.PreAuthenticate = true; req.KeepAlive = true; req.Timeout = 50000; req.AllowAutoRedirect = false; req.ContentLength = s_JSON.Length; Stream s = req.GetRequestStream(); s.Write(System.Text.Encoding.ASCII.GetBytes(s_JSON), 0, s_JSON.Length); s.Close(); HttpWebResponse resp = (HttpWebResponse)req.GetResponse(); res = "Created: " + resp.Headers["Location"]; } catch (Exception e) { res = "Error: " + e.Message + e.Data; } Console.WriteLine(res); return rc; }
public TestStuffLib(TestStuffTransaction _TestStuffTransaction) { this.CurrentTestStuffTransaction = _TestStuffTransaction; }