コード例 #1
0
 public void TestSuiteExecutionComplete(QTF.TestSuite testSuite, QTF.TestExecutionCompleteEventArgs eventArgs)
 {
     // Enter runtime event handler code here
 }
コード例 #2
0
        public QTF.TestVerdict CreateTestCaseWithTestStep(string testSuiteFile)
        {
            try
            {
                Setup();

                QTF.TestSuite testSuite = QTF.TestSuite.ReadFromFile(testSuiteFile);

                foreach (QTF.TestScriptObject testScriptObject in testSuite.TestScriptObjects)
                {
                    QTF.TestTrace.Trace("Test case:  " + testScriptObject.Title);

                    if (testScriptObject is QTF.TestCase)
                    {
                        QTF.TestCase testCase = testScriptObject as QTF.TestCase;

                        foreach (QTF.TestStep testStep in testCase.TestSteps)
                        {
                            QTF.TestTrace.Trace("Test step:  " + testStep.Title);
                        }
                    }
                }

                /*
                 *
                 *            //foreach(TestScriptObject testSuite.TestScriptObjects
                 *
                 *
                 *            //var client = new WebClient { Credentials = new NetworkCredential("jmothershead", "Invalid!") };
                 *            //client.Headers.Add(HttpRequestHeader.ContentType, "application/xml"); // you also can use application/json content type
                 *
                 *            string address = "https://quintity.tpondemand.com/api/v1"; ;
                 *
                 *            WebRequest request = (HttpWebRequest)WebRequest.Create(address + "/TestSteps");
                 *            request.Credentials = new NetworkCredential("jmothershead", "Invalid!");
                 *            request.Method = WebRequestMethods.Http.Post;
                 *            request.ContentType = "application/xml";
                 *
                 *            //string postData = "<Project Name=\"My spanking new project\"/>";
                 *            //string postData = "<UserStory Name=\"My new story\" Project=\"My spanking new project\"/>";
                 *            //string postData = "<TestCase Name=\"Test case #15\" Description=\"Test case description\"><Steps>" +
                 *            //    "<TestStep><Description>Step1</Description><Result>Step1Result</Result></TestStep></Steps><UserStory Id=\"219\"/></TestCase>";
                 *            //string postData = "<TestCase Name=\"Test case #5\" Description=\"Test case description\"></TestCase>";
                 *
                 *            string postData = "<TestStep><TestCase Id=\"241\"/><Description>Step1</Description><Result>Step1Result</Result></TestStep>";
                 *
                 *            //<TestCase Id=\"222\"</TestCase>
                 *
                 *            //string postData = "{\"TestPlan\": {\"Id\": 225}, \"Name\": \"Joe\", \"Project\": {\"Id\": 214}, \"TestCaseRuns\": [{\"Comment\": \"Nevermind\"}]}";
                 *
                 *            //"{\"TestPlan\": {\"Id\": 225}, " +
                 *            //"\"Name\": \"Test plan run 2\", " +
                 *            //"\"Project\": {\"Id\": 214}, " +
                 *            //"\"Priority\": {\"Name\" : \"-\"}, " +
                 *            //"\"EntityState\": {\"Name\" : \"Open\"}";
                 *            //"\"TestCaseRuns\": [{\"Comment\": \"Nevermind\"}]}";
                 *
                 *            //string postData =
                 *            //    "<TestPlanRun Name=\"Test plan run 2\">" +
                 *            //    "<Project Id =\"214\"/>" +
                 *            //    "<TestPlan Id=\"225\"/>" +
                 *            //    "<Priority Name =\"-\"/>" +
                 *            //    "<EntityState Name=\"Open\"/>" +
                 *            //    "</TestPlanRun>";
                 *
                 *            request.ContentLength = postData.Length;
                 *
                 *            StreamWriter postStream = new StreamWriter(request.GetRequestStream(), System.Text.Encoding.ASCII);
                 *            postStream.Write(postData);
                 *            postStream.Close();
                 *
                 *            HttpWebResponse response = (HttpWebResponse)request.GetResponse();
                 *
                 *            //if (response.StatusCode == HttpStatusCode.OK)
                 *            //{
                 *            QTF.TestTrace.Trace(string.Format("Response Status Code is OK and StatusDescription is: {0}",
                 *                                 response.StatusDescription));
                 *            //}
                 *
                 *            // Get the stream associated with the response.
                 *            Stream receiveStream = response.GetResponseStream();
                 *
                 *            // Pipes the stream to a higher level stream reader with the required encoding format.
                 *            StreamReader readStream = new StreamReader(receiveStream, Encoding.UTF8);
                 *
                 *            //Console.WriteLine("Response stream received.");
                 *            TestMessage = readStream.ReadToEnd();
                 *
                 *            // Releases the resources of the response.
                 *            response.Close();
                 *
                 *            //var xmlResult = XDocument.Parse(client.DownloadString(address + "/Projects"));
                 *
                 *            //File.WriteAllText(@"c:\temp\userstories.xml", xmlResult.ToString());
                 *
                 *            TestVerdict = QTF.TestVerdict.Pass;
                 *            //TestMessage = xmlResult.ToString();
                 */
            }
            catch (Exception e)
            {
                TestMessage += e.ToString();
                TestVerdict  = QTF.TestVerdict.Error;
            }
            finally
            {
                Teardown();
            }

            return(TestVerdict);
        }
コード例 #3
0
 public void TestPostprocessorExecutionBegin(QTF.TestSuite testSuite, QTF.TestProcessBeginEventArgs eventArgs)
 {
     // Enter runtime event handler code here
 }
コード例 #4
0
 public void TestSuiteExecutionBegin(QTF.TestSuite testSuite)
 {
     // Enter runtime event handler code here
 }
コード例 #5
0
        public QTF.TestVerdict MyTestMethod(
            [QTF.TestParameter("String parameter", "Enter string parameter", "Default value")]
            string param1,
            [QTF.TestParameter("Int parameter", "Enter integer parameter", 0)]
            int param2,
            [QTF.TestParameter("Boolean parameter", "Enter boolean parameter", true)]
            bool param3)
        {
            try
            {
                Setup();

                QTF.TestSuite testSuite = QTF.TestSuite.DeserializeFromFile(@"C:\TestProjects\Quintity\Quintity.TestFramework\Quintity.TestFramework - Trunk\Quintity.TestFramework.Scratch\TestSuites\Quintity.TestFramework.Scratch.Tests.ste");

                //QTF.TestSuite testSuite = new QTF.TestSuite("MyTestSuite");

                // QTF.TestExecutor.TraverseTestTree(testSuite, new QTF.TestExecutor.TraverseTestTreeDelegate(ConstructNodeTree));

                Thread.Sleep(5000);

                //QTF.TestExecutor.WalkTestTree(testSuite, new QTF.TestExecutor.WalkTestTreeDelegate(TraceOut));

                //QTF.TestAutomationDefinition firstdefinition = new QTF.TestAutomationDefinition();
                //firstdefinition.TestAssembly = "TestAssembly";
                //firstdefinition.TestClass = "TestClass";
                //firstdefinition.TestMethod = "TestMethod";
                //firstdefinition.TestParameters = new QTF.TestParameterCollection();
                //firstdefinition.TestParameters.Add(new QTF.TestParameter("Parameter1", "Parameter2", "OriginalName", typeof(string)));

                //QTF.TestAutomationDefinition seconddefinition = new QTF.TestAutomationDefinition(firstdefinition);

                //firstdefinition.TestParameters[0].Name = "spud";


                //QTF.TestWarning.Fail("This is a failed warning comment.");

                //QTF.TestTrace.Trace("This is a sample TestTrace message.");

                ////for (int i = 1; i <= param2; i++)
                ////{
                ////    QTF.TestCheck.IsFalse(string.Format("Test check {0}", i), param3, "This is a sample TestCheck.");
                ////}

                //QTF.TestCheck.Fail("This is the first failed test check.");
                //QTF.TestCheck.Fail("This is the second failed test check.");
                //QTF.TestCheck.Fail("This is the third failed test check.");

                //Thread.Sleep(3000);

                TestMessage += "This is the test message.";
                TestVerdict  = param3 ? QTF.TestVerdict.Pass : QTF.TestVerdict.Fail;
            }
            catch (QTF.TestCheckFailedException e)
            {
                TestMessage += e.ToString();
                TestVerdict  = QTF.TestVerdict.Fail;
            }
            catch (Exception e)
            {
                TestMessage += e.ToString();
                TestVerdict  = QTF.TestVerdict.Error;
            }
            finally
            {
                Teardown();
            }

            return(TestVerdict);
        }
コード例 #6
0
 public TestCase(TestSuite parent, XPathNavigator nav)
     : base(null, parent)
 {
     Read(parent, nav);
 }
コード例 #7
0
 public TestCase(string title, TestSuite parent)
     : base(title, parent)
 {
     _onTestStepFailure = OnFailure.Stop;
 }