Пример #1
0
        /// <summary>
        /// Starting a new test
        /// </summary>
        /// <param name="name"> test's name </param>
        /// <param name="context"> context tags to be attached to this practicular test </param>
        /// <returns> current test id </returns>
        public void TestStart(string name, ReportingTestContext context)
        {
            // Send test-start command
            Dictionary <string, object> param = new Dictionary <string, object>();
            Job job = perfectoExecutionContext.Job;

            if (job != null)
            {
                param.Add("jobName", job.Name);
                param.Add("jobNumber", job.Number);
                param.Add("jobBranch", job.Branch);
            }
            Project project = perfectoExecutionContext.Project;

            if (project != null)
            {
                param.Add("projectName", project.Name);
                param.Add("projectVersion", project.Version);
            }

            param.Add("name", name);
            List <string> tags = new List <string>(perfectoExecutionContext.ContextTags);

            tags.AddRange(context.GetTestExecutionTags());
            param.Add(TAGS_PARAM_NAME, tags);

            List <string>    customFieldsPair     = new List <string>();
            HashSet <string> existingCustomFields = new HashSet <string>();

            createCustomFieldsParamsValuePairs(context.GetCustomFields(), existingCustomFields, customFieldsPair);
            createCustomFieldsParamsValuePairs(perfectoExecutionContext.CustomFields, existingCustomFields, customFieldsPair);
            param.Add(CUSTOM_FIELDS_PARAM_NAME, customFieldsPair);

            ExecuteScript(START_TEST_COMMAND, param);
        }
Пример #2
0
        public void TestStop(TestResult testResult, ReportingTestContext testContext)
        {
            //if (currentTestId == null || currentTestId.Equals(""))
            //{
            //	// Short-circuit if previous call to testStart failed
            //	return;
            //}
            Dictionary <string, object> param = new Dictionary <string, object>();
            bool isSuccessful = testResult.IsSuccessful();

            param.Add(SUCCESS_PARAM_NAME, isSuccessful);
            if (!isSuccessful)
            {
                param.Add(FAILURE_DESCRIPTION_PARAM_NAME, testResult.GetMessage());
                string failureReasonName = testResult.GetFailureReasonName();
                if (!string.IsNullOrEmpty(failureReasonName))
                {
                    param.Add(FAILURE_REASON_PARAM_NAME, failureReasonName);
                }
            }

            if (testContext != null)
            {
                ICollection <string> testExecutionTags = testContext.GetTestExecutionTags();
                if (testExecutionTags != null && testExecutionTags.Count > 0)
                {
                    List <String> tags = new List <string>(testExecutionTags);
                    param.Add(TAGS_PARAM_NAME, tags);
                }

                ICollection <CustomField> customFields = testContext.GetCustomFields();
                if (customFields != null && customFields.Count > 0)
                {
                    List <string> customFieldsPair = new List <string>();
                    createCustomFieldsParamsValuePairs(customFields, new HashSet <string>(), customFieldsPair);
                    param.Add(CUSTOM_FIELDS_PARAM_NAME, customFieldsPair);
                }
            }

            ExecuteScript(END_TEST_COMMAND, param);
        }