Esempio n. 1
0
        /// <summary>
        /// Send the provided GUI/API Testing Results to the Slack Instance configured with QViz
        /// </summary>
        /// <param name="testResult">GUI or API Test Results as JSON Object</param>
        /// <param name="slackURL">URL of the Slack Hooks for sending Messages</param>
        /// <param name="projectID">Identifier for the Project</param>
        /// <param name="projectName">Name of the Project</param>
        /// <param name="projectType">Type of the Project</param>
        /// <param name="qvizURL">URL to the QViz App Instance</param>
        /// <param name="runID">Identifier for the Run</param>
        public void SendTestResultsToSlack(
            object testResult,
            string slackURL,
            string projectID,
            string projectName,
            string projectType,
            string qvizURL,
            string runID)
        {
            var apiClient = new APIClient(_baseURL);

            apiClient.Headers.Add(new KeyValue("Content-Type", "application/json"));
            apiClient.Headers.Add(new KeyValue("Authorization", "Bearer " + _user.access_token));
            apiClient.Queries.Add(new KeyValue("userId", _user.userId));
            apiClient.Queries.Add(new KeyValue("projectId", projectID));
            apiClient.Queries.Add(new KeyValue("slackURL", slackURL));
            apiClient.Queries.Add(new KeyValue("ProjectName", projectName));
            apiClient.Queries.Add(new KeyValue("type", projectType));
            apiClient.Queries.Add(new KeyValue("QIFURL", qvizURL));
            apiClient.Queries.Add(new KeyValue("runId", runID));
            apiClient.Body = testResult;
            apiClient.Post <object>("/api/integration/Slack");
            _lastResponse = apiClient.Response.Content;
            if (!apiClient.Response.IsSuccessful)
            {
                throw apiClient.GetError();
            }
        }
Esempio n. 2
0
        /// <summary>
        /// Get the list of API Test Cases associated with the specified Project
        /// </summary>
        /// <param name="projectId">Identifier for the Project to fetch API Test Cases from</param>
        /// <param name="onlyAutomated">Get only the API Test Cases that are Automated?</param>
        /// <param name="onlyDescription">Get only the API Test Case(s) that matches the Description?</param>
        /// <returns>List of API Test Cases as Array of Objects</returns>
        /// <exception cref="Exception">In case of failure</exception>
        public List <TestCaseAPI> GetAPITestCases(
            string projectId,
            bool onlyAutomated     = false,
            string onlyDescription = "")
        {
            var apiClient = new APIClient(_baseURL);

            apiClient.Headers.Add(new KeyValue("Content-Type", "application/json"));
            apiClient.Headers.Add(new KeyValue("Authorization", "Bearer " + _user.access_token));
            apiClient.Queries.Add(new KeyValue("projectId", projectId));
            var apiCases = apiClient.Get <List <TestCaseAPI> >("/api/apiTestcases");

            _lastResponse = apiClient.Response.Content;
            if (!apiClient.Response.IsSuccessful)
            {
                throw apiClient.GetError();
            }
            // Filter only Automated Test Cases (if requested)
            if (onlyAutomated)
            {
                apiCases = apiCases.Where(tc => tc.isAutomated.Equals(true)).ToList();
            }

            // Filter only Test Cases that matches the Description (if requested)
            if (!string.IsNullOrEmpty(onlyDescription))
            {
                apiCases = apiCases.Where(
                    tc => tc.description.Equals(onlyDescription, StringComparison.CurrentCultureIgnoreCase)).ToList();
            }

            return(apiCases);
        }
Esempio n. 3
0
        /// <summary>
        /// Authenticate with QViz using the provided User credentials
        /// </summary>
        /// <param name="userName">Name of the User</param>
        /// <param name="password">Password of the User</param>
        /// <exception cref="Exception">In case of failure</exception>
        public void Authenticate(string userName, string password)
        {
            var authentication = new Authentication(userName, password);
            var apiClient      = new APIClient(_baseURL);

            apiClient.Headers.Add(new KeyValue("Content-Type", "application/json"));
            apiClient.Body = authentication;
            _user          = apiClient.Post <AccessUser>("/api/authentication");
            _lastResponse  = apiClient.Response.Content;
            if (!apiClient.Response.IsSuccessful)
            {
                throw apiClient.GetError();
            }
        }
Esempio n. 4
0
        /// <summary>
        /// Post the provided Module to the QViz Instance
        /// </summary>
        /// <param name="SubModule">SubModule as JSON Object</param>
        public void PostSubModule(SubModule SubModule)
        {
            var apiClient = new APIClient(_baseURL);

            apiClient.Headers.Add(new KeyValue("Content-Type", "application/json"));
            apiClient.Headers.Add(new KeyValue("Authorization", "Bearer " + _user.access_token));
            apiClient.Headers.Add(new KeyValue("userId", _user.userId));
            apiClient.Body = SubModule;
            apiClient.Post <object>("/api/sub-modules");
            _lastResponse = apiClient.Response.Content;
            if (!apiClient.Response.IsSuccessful)
            {
                throw apiClient.GetError();
            }
        }
Esempio n. 5
0
        /// <summary>
        /// Post the provided GUI Test to the QViz Instance
        /// </summary>
        /// <param name="guiTest">GUI Test as JSON Object</param>
        public void PostGUITest(TestCaseGUI guiTest)
        {
            var apiClient = new APIClient(_baseURL);

            apiClient.Headers.Add(new KeyValue("Content-Type", "application/json"));
            apiClient.Headers.Add(new KeyValue("Authorization", "Bearer " + _user.access_token));
            apiClient.Headers.Add(new KeyValue("userId", _user.userId));
            apiClient.Body = guiTest;
            apiClient.Post <object>("/api/uiTestcases");
            _lastResponse = apiClient.Response.Content;
            if (!apiClient.Response.IsSuccessful)
            {
                throw apiClient.GetError();
            }
        }
Esempio n. 6
0
        /// <summary>
        /// Get the list of Projects associated with the User
        /// </summary>
        /// <returns>List of Projects as Array of Objects</returns>
        /// <exception cref="Exception">In case of failure</exception>
        public List <Project> GetProjects()
        {
            var apiClient = new APIClient(_baseURL);

            apiClient.Headers.Add(new KeyValue("Content-Type", "application/json"));
            apiClient.Headers.Add(new KeyValue("Authorization", "Bearer " + _user.access_token));
            apiClient.Queries.Add(new KeyValue("userId", _user.userId));
            var projects = apiClient.Get <List <Project> >("/api/projects");

            _lastResponse = apiClient.Response.Content;
            if (!apiClient.Response.IsSuccessful)
            {
                throw apiClient.GetError();
            }
            return(projects);
        }
Esempio n. 7
0
        public List <Tool> GetTools(string projecId)
        {
            var apiClient = new APIClient(_baseURL);

            apiClient.Headers.Add(new KeyValue("Content-Type", "application/json"));
            apiClient.Headers.Add(new KeyValue("Authorization", "Bearer " + _user.access_token));
            apiClient.Queries.Add(new KeyValue("projectId", projecId));
            var tools = apiClient.Get <List <Tool> >("api/tools");

            if (!apiClient.Response.IsSuccessful)
            {
                throw apiClient.GetError();
            }

            return(tools);
        }
Esempio n. 8
0
        /// <summary>
        /// Post the provided test Suite to the QViz Instance
        /// </summary>
        /// <param name="testSuite">Test Suite as JSON Object</param>
        //public void PostTestSuite(SubModule testSuite)
        //{
        //	var apiClient = new APIClient(_baseURL);
        //	apiClient.Headers.Add(new KeyValue("Content-Type", "application/json"));
        //	apiClient.Headers.Add(new KeyValue("Authorization", "Bearer " + _user.access_token));
        //	apiClient.Headers.Add(new KeyValue("userId", _user.userId));
        //	apiClient.Body = testSuite;
        //	apiClient.Post<object>("/api/TestSuites");
        //	_lastResponse = apiClient.Response.Content;
        //	if (!apiClient.Response.IsSuccessful) throw apiClient.GetError();
        //}


        /// <summary>
        /// Get test case type
        /// </summary>
        /// <returns>List of test case type</returns>
        public List <TestCaseType> GetTestCaseTypes()
        {
            var apiClient = new APIClient(_baseURL);

            apiClient.Headers.Add(new KeyValue("Content-Type", "application/json"));
            apiClient.Headers.Add(new KeyValue("Authorization", "Bearer " + _user.access_token));

            var TCtypes = apiClient.Get <List <TestCaseType> >("api/testcasetypes");

            if (!apiClient.Response.IsSuccessful)
            {
                throw apiClient.GetError();
            }

            return(TCtypes);
        }
Esempio n. 9
0
        /// <summary>
        /// Get SubModule under a module in project
        /// </summary>
        /// <param name="moduleId"></param>
        /// <returns></returns>
        public List <SubModule> GetSubModules(string moduleId)
        {
            var apiClient = new APIClient(_baseURL);

            apiClient.Headers.Add(new KeyValue("Content-Type", "application/json"));
            apiClient.Headers.Add(new KeyValue("Authorization", "Bearer " + _user.access_token));
            apiClient.Queries.Add(new KeyValue("moduleId", moduleId));
            var subModules = apiClient.Get <List <SubModule> >("/api/sub-modules");

            _lastResponse = apiClient.Response.Content;
            if (!apiClient.Response.IsSuccessful)
            {
                throw apiClient.GetError();
            }
            return(subModules);
        }
Esempio n. 10
0
        /// <summary>
        /// Send the provided GUI/API Testing Results to the JIRA Instance configured with QViz
        /// </summary>
        /// <param name="testResult">GUI or API Test Results as JSON Object</param>
        /// <param name="jiraURL">URL of the JIRA REST v2 API Instance</param>
        /// <param name="userName">Unique Name of the JIRA User</param>
        /// <param name="apiToken">JIRA REST v2 API Access Token of the User</param>
        public void SendTestResultsToJIRA(
            object testResult,
            string jiraURL,
            string userName,
            string apiToken)
        {
            var apiClient = new APIClient(_baseURL);

            apiClient.Headers.Add(new KeyValue("Content-Type", "application/json"));
            apiClient.Headers.Add(new KeyValue("Authorization", "Bearer " + _user.access_token));
            apiClient.Queries.Add(new KeyValue("jiraAPIURL", jiraURL));
            apiClient.Queries.Add(new KeyValue("username", userName));
            apiClient.Queries.Add(new KeyValue("passwordKey", apiToken));
            apiClient.Queries.Add(new KeyValue("postComment", "true"));
            apiClient.Queries.Add(new KeyValue("logDefect", "true"));
            apiClient.Body = testResult;
            apiClient.Post <object>("/api/integration/Jira");
            _lastResponse = apiClient.Response.Content;
            if (!apiClient.Response.IsSuccessful)
            {
                throw apiClient.GetError();
            }
        }
Esempio n. 11
0
        /// <summary>
        /// Send the provided GUI/API Testing Results to the Test Rail Instance configured with QViz
        /// </summary>
        /// <param name="testResult">GUI or API Test Results as JSON Object</param>
        /// <param name="testRailURL">URL of the TestRail Instance</param>
        /// <param name="userName">Unique Name of the TestRail User</param>
        /// <param name="apiToken">API Access Key of the TestRail User</param>
        /// <param name="testRailRunID">Identifier for the Test Run from TestRail Instance</param>
        /// <param name="lastError">Last Error Message (if any)</param>
        public void SendTestResultsToTestRail(
            object testResult,
            string testRailURL,
            string userName,
            string apiToken,
            string testRailRunID,
            string lastError)
        {
            var apiClient = new APIClient(_baseURL);

            apiClient.Headers.Add(new KeyValue("Content-Type", "application/json"));
            apiClient.Headers.Add(new KeyValue("Authorization", "Bearer " + _user.access_token));
            apiClient.Queries.Add(new KeyValue("TestRailURL", testRailURL));
            apiClient.Queries.Add(new KeyValue("username", userName));
            apiClient.Queries.Add(new KeyValue("passwordKey", apiToken));
            apiClient.Queries.Add(new KeyValue("postResult", "true"));
            apiClient.Queries.Add(new KeyValue("TestRailRunID", testRailRunID));
            if (lastError != null && lastError.StartsWith("Defect", StringComparison.CurrentCultureIgnoreCase))
            {
                apiClient.Queries.Add(
                    new KeyValue(
                        "Defect",
                        lastError.Split(": ".ToCharArray())[1].Split("::".ToCharArray())[0]
                        .Replace(" :", "")
                        )
                    );
            }

            apiClient.Body = testResult;
            apiClient.Post <object>("/api/integration/TestRail");
            _lastResponse = apiClient.Response.Content;
            if (!apiClient.Response.IsSuccessful)
            {
                throw apiClient.GetError();
            }
        }