Beispiel #1
0
 // Instance Constructor
 public XMLUtils()
 {
     reader        = null;
     testcaseEnv   = new TestcaseEnvironment();
     testcaseSuite = new TestcaseSuite();
     count         = 0;
     flag          = false;
 }
Beispiel #2
0
        public void writeResult(String path, String fileName, TestcaseEnvironment testEnv, List <TestcaseData> list)
        {
            try
            {
                FileStream   fs = new FileStream(path + fileName, FileMode.Create);
                StreamWriter sw = new StreamWriter(fs);

                XmlWriter xmlWriter = XmlWriter.Create(sw);
                xmlWriter.WriteStartDocument();

                xmlWriter.WriteStartElement("test_definition");

                xmlWriter.WriteStartElement("suite");
                xmlWriter.WriteAttributeString("category", "");
                xmlWriter.WriteAttributeString("extension", "");
                xmlWriter.WriteAttributeString("name", "");

                xmlWriter.WriteStartElement("set");
                xmlWriter.WriteAttributeString("name", "C#");
                xmlWriter.WriteAttributeString("set_debug_msg", "N/A");
                xmlWriter.WriteAttributeString("type", "js");

                /* MAKE TESTCASE */
                foreach (TestcaseData data in list)
                {
                    xmlWriter.WriteStartElement("testcase");
                    xmlWriter.WriteAttributeString("component", data.component);
                    xmlWriter.WriteAttributeString("execution_type", data.execution_type);
                    xmlWriter.WriteAttributeString("id", data.id);
                    xmlWriter.WriteAttributeString("priority", data.priority);
                    xmlWriter.WriteAttributeString("purpose", data.purpose);
                    xmlWriter.WriteAttributeString("onload_delay", data.onloaddelay);
                    xmlWriter.WriteAttributeString("result", data.result);

                    /*
                     * <description>
                     *  <test_script_entry>/opt/tct-messaging-mms-tizen-tests/messaging/MessageBody_mms_extend.html</test_script_entry>
                     * </description>
                     */
                    xmlWriter.WriteStartElement("description");
                    xmlWriter.WriteStartElement("test_script_entry");
                    xmlWriter.WriteString(data.test_script_entry);
                    xmlWriter.WriteEndElement(); // close test_script_entry
                    xmlWriter.WriteEndElement(); // close description

                    /*
                     * <result_info>
                     *  <actual_result>PASS</actual_result>
                     *  <start>2016-04-01 16:53:06</start>
                     *  <end>2016-04-01 16:53:07</end>
                     *  <stdout>[Message]</stdout>
                     *  <stderr />
                     * </result_info>
                     */
                    xmlWriter.WriteStartElement("result_info");

                    xmlWriter.WriteStartElement("actual_result");
                    xmlWriter.WriteString(data.actual_result);
                    xmlWriter.WriteEndElement(); // end of atcual_result

                    xmlWriter.WriteStartElement("start");
                    xmlWriter.WriteString(data.start);
                    xmlWriter.WriteEndElement(); // end of start

                    xmlWriter.WriteStartElement("end");
                    xmlWriter.WriteString(data.end);
                    xmlWriter.WriteEndElement(); // end of end

                    xmlWriter.WriteStartElement("stdout");
                    xmlWriter.WriteString(data.stdout);
                    xmlWriter.WriteEndElement(); // end of stdout

                    xmlWriter.WriteStartElement("stderr");
                    xmlWriter.WriteString(data.stderr);
                    xmlWriter.WriteEndElement(); // end of stderr

                    xmlWriter.WriteEndElement(); // end of resultinfo


                    xmlWriter.WriteEndElement(); // end of testcase
                }
                xmlWriter.WriteEndElement();     // end of set
                xmlWriter.WriteEndElement();     // end of suite

                xmlWriter.WriteEndDocument();

                xmlWriter.Dispose();

                sw.Dispose();
                fs.Dispose();
            }
            catch (Exception e)
            {
                LogUtils.Write(LogUtils.ERROR, LogUtils.TAG, "ERROR :: : " + e.Message);
            }
        }