Ejemplo n.º 1
0
        public QTF.TestVerdict PassingSimpleClassMethod(
            [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,
            QTF.TestCase param4)
        {
            try
            {
                Setup();

                //QTF.TestCase testcase = QTF.TestProperties.GetValue("TestCase") as QTF.TestCase;

                //QTF.TestProperties.SetProperty("bummer", new SimpleClass());
                System.Reflection.Assembly assy = System.Reflection.Assembly.GetExecutingAssembly();
                QTF.TestProperties.SetPropertyValue("assembly", assy);

                List <Type> knownTypes = new List <Type>();
                knownTypes.Add(assy.GetType());
                QTF.TestProperties.Save(@"c:\temp\dork.xml", knownTypes);
                TestMessage += param1;
                TestVerdict  = QTF.TestVerdict.Pass;
            }
            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);
        }
Ejemplo n.º 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);
        }
 public void TestCaseExecutionComplete(QTF.TestCase testCase, QTF.TestExecutionCompleteEventArgs eventArgs)
 {
     // Enter runtime event handler code here
 }
 public void TestCaseExecutionBegin(QTF.TestCase testCase)
 {
     // Enter runtime event handler code here
 }
Ejemplo n.º 5
0
 public TestStep(TestCase parent, XPathNavigator nav)
     : base(title: null, parent: parent)
 {
     Read(parent, nav);
 }
Ejemplo n.º 6
0
 public static void SerializeToFile(TestCase testCase, string filePath)
 {
     TestArtifact.SerializeToFile(testCase, filePath);
 }
Ejemplo n.º 7
0
 private void FireExecutionBeginEvent(TestCase testCase, TestCaseBeginExecutionArgs args)
 {
     OnExecutionBegin?.Invoke(testCase, args);
 }