Пример #1
0
            public void RunFinished()
            {
                var resultDestiantion = Application.dataPath;

                if (!string.IsNullOrEmpty(m_ResultFilePath))
                {
                    resultDestiantion = m_ResultFilePath;
                }
                var fileName = Path.GetFileName(resultDestiantion);

                if (!string.IsNullOrEmpty(fileName))
                {
                    resultDestiantion = resultDestiantion.Substring(0, resultDestiantion.Length - fileName.Length);
                }
                else
                {
                    fileName = "UnitTestResults.xml";
                }
#if !UNITY_METRO
                var resultWriter = new XmlResultWriter("Unit Tests", "Editor", m_Results.ToArray());
                resultWriter.WriteToFile(resultDestiantion, fileName);
#endif
                var executed = m_Results.Where(result => result.Executed);
                if (!executed.Any())
                {
                    EditorApplication.Exit(returnCodeRunError);
                    return;
                }
                var failed = executed.Where(result => !result.IsSuccess);
                EditorApplication.Exit(failed.Any() ? returnCodeTestsFailed : returnCodeTestsOk);
            }
Пример #2
0
            public void RunFinished()
            {
                var resultDestiantion = Application.dataPath;

                if (!string.IsNullOrEmpty(resultFilePath))
                {
                    resultDestiantion = resultFilePath;
                }
                var fileName = Path.GetFileName(resultDestiantion);

                if (!string.IsNullOrEmpty(fileName))
                {
                    resultDestiantion = resultDestiantion.Substring(0, resultDestiantion.Length - fileName.Length);
                }
                else
                {
                    fileName = "UnitTestResults.xml";
                }
#if !UNITY_METRO
                var resultWriter = new XmlResultWriter("Unit Tests", results.ToArray());
                resultWriter.WriteToFile(resultDestiantion, fileName);
#endif
                var executed = results.Where(result => result.Executed);
                if (!executed.Any())
                {
                    EditorApplication.Exit(RETURN_CODE_RUN_ERROR);
                    return;
                }
                var failed = executed.Where(result => !result.IsSuccess);
                EditorApplication.Exit(failed.Any() ? RETURN_CODE_TESTS_FAILED : RETURN_CODE_TESTS_OK);
            }
Пример #3
0
        private void SaveResults()
        {
            if (!IsFileSavingSupported())
            {
                return;
            }
            var resultDestiantion = GetResultDestiantion();
            var resultFileName    = Application.loadedLevelName;

            if (resultFileName != "")
            {
                resultFileName += "-";
            }
            resultFileName += defaultResulFilePostfix;

            var resultWriter = new XmlResultWriter(Application.loadedLevelName, testToRun.ToArray());

#if !UNITY_METRO
            Uri uri;
            if (Uri.TryCreate(resultDestiantion, UriKind.Absolute, out uri) && uri.Scheme == Uri.UriSchemeFile)
            {
                resultWriter.WriteToFile(resultDestiantion, resultFileName);
            }
            else
            {
                Debug.LogError("Provided path is invalid");
            }
#endif
        }
            public void RunFinished()
            {
                var resultWriter = new XmlResultWriter("UnitTestResults.xml");

                resultWriter.SaveTestResult("Unit Tests", unitTestView.testList.ToArray());
                EditorUtility.ClearProgressBar();
            }
Пример #5
0
            public void RunFinished()
            {
                var resultDestiantion = Application.dataPath;

                if (!string.IsNullOrEmpty(resultFilePath))
                {
                    resultDestiantion = resultFilePath;
                }

                var fileName = Path.GetFileName(resultDestiantion);

                if (!string.IsNullOrEmpty(fileName))
                {
                    resultDestiantion = resultDestiantion.Substring(0, resultDestiantion.Length - fileName.Length);
                }

                else
                {
                    fileName = "UnitTestResults.xml";
                }

#if !UNITY_METRO
                var resultWriter = new XmlResultWriter("Unit Tests", results.ToArray());
                resultWriter.WriteToFile(resultDestiantion, fileName);
#endif
            }
Пример #6
0
        private void WriteResultsToFile()
        {
            var path = System.IO.Path.Combine(Application.dataPath,
                                              Application.loadedLevelName + "-TestResults.xml");
            var resultWriter = new XmlResultWriter(Application.loadedLevelName, path);

            resultWriter.SaveTestResult(testToRun.ToArray());
        }
Пример #7
0
            public void RunFinished()
            {
                var resultWriter = new XmlResultWriter(EditorApplication.currentScene,
                                                       "UnitTestResults.xml");

                resultWriter.SaveTestResult(unitTestView.testList.ToArray());
                EditorUtility.ClearProgressBar();
            }
Пример #8
0
        private void WriteResultsToFile()
        {
            string path = Path.Combine(Application.dataPath, Application.loadedLevelName + "-TestResults.xml");

            Debug.Log("Saving results in " + path);
            var resultWriter = new XmlResultWriter(path);

            resultWriter.SaveTestResult(Application.loadedLevelName, testToRun.ToArray());
        }
        private void AcceptCallback(TcpClient client)
        {
            m_Repaint = true;
            ResultDTO dto;

            try
            {
                m_LastMessageReceived = DateTime.Now;
                using (var stream = client.GetStream())
                {
                    var bf = new DTOFormatter();
                    dto = (ResultDTO)bf.Deserialize(stream);
                    stream.Close();
                }
                client.Close();
            }
            catch (ObjectDisposedException e)
            {
                Debug.LogException(e);
                m_StatusLabel = "Got disconnected";
                return;
            }
            catch (Exception e)
            {
                Debug.LogException(e);
                return;
            }

            switch (dto.messageType)
            {
            case ResultDTO.MessageType.TestStarted:
                m_StatusLabel = dto.testName;
                m_TestTimeout = TimeSpan.FromSeconds(dto.testTimeout);
                break;

            case ResultDTO.MessageType.TestFinished:
                m_TestResults.Add(dto.testResult);
                m_TestTimeout = TimeSpan.Zero;
                if (dto.testResult.Executed && dto.testResult.ResultState != TestResultState.Ignored && !dto.testResult.IsSuccess)
                {
                    m_TestFailed = true;
                }
                break;

            case ResultDTO.MessageType.RunStarted:
                m_TestResults = new List <ITestResult>();
                m_StatusLabel = "Run started: " + dto.loadedLevelName;
                break;

            case ResultDTO.MessageType.RunFinished:
                WriteResultsToLog(dto, m_TestResults);
                if (!string.IsNullOrEmpty(m_Configuration.resultsDir))
                {
                    var platform     = m_Configuration.runInEditor ? "Editor" : m_Configuration.buildTarget.ToString();
                    var resultWriter = new XmlResultWriter(dto.loadedLevelName, platform, m_TestResults.ToArray());
                    try
                    {
                        if (!Directory.Exists(m_Configuration.resultsDir))
                        {
                            Directory.CreateDirectory(m_Configuration.resultsDir);
                        }
                        var filePath = Path.Combine(m_Configuration.resultsDir, dto.loadedLevelName + ".xml");
                        File.WriteAllText(filePath, resultWriter.GetTestResult());
                    }
                    catch (Exception e)
                    {
                        Debug.LogException(e);
                    }
                }
                break;

            case ResultDTO.MessageType.AllScenesFinished:
                m_Running     = false;
                m_RunFinished = true;
                break;

            case ResultDTO.MessageType.Ping:
                break;
            }
        }
        private void AcceptCallback(TcpClient client)
        {
            m_Repaint = true;
            ResultDTO dto;
            try
            {
                m_LastMessageReceived = DateTime.Now;
                using (var stream = client.GetStream())
                {
                    var bf = new BinaryFormatter();
                    dto = (ResultDTO)bf.Deserialize(stream);
                    stream.Close();
                }
                client.Close();
            }
            catch (ObjectDisposedException e)
            {
                Debug.LogException(e);
                m_StatusLabel = "Got disconnected";
                return;
            }
            catch (Exception e)
            {
                Debug.LogException(e);
                return;
            }

            switch (dto.messageType)
            {
                case ResultDTO.MessageType.TestStarted:
                    m_StatusLabel = dto.testName;
                    m_TestTimeout = TimeSpan.FromSeconds(dto.testTimeout);
                    break;
                case ResultDTO.MessageType.TestFinished:
                    m_TestResults.Add(dto.testResult);
                    m_TestTimeout = TimeSpan.Zero;
                    if (dto.testResult.Executed && dto.testResult.ResultState != TestResultState.Ignored && !dto.testResult.IsSuccess)
                        m_TestFailed = true;
                    break;
                case ResultDTO.MessageType.RunStarted:
                    m_TestResults = new List<ITestResult>();
                    m_StatusLabel = "Run started: " + dto.loadedLevelName;
                    break;
                case ResultDTO.MessageType.RunFinished:
                    WriteResultsToLog(dto, m_TestResults);
                    if (!string.IsNullOrEmpty(m_Configuration.resultsDir))
                    {
                        var platform = m_Configuration.runInEditor ? "Editor" : m_Configuration.buildTarget.ToString();
                        var resultWriter = new XmlResultWriter(dto.loadedLevelName, platform, m_TestResults.ToArray());
                        try
                        {
                            var filePath = Path.Combine(m_Configuration.resultsDir, dto.loadedLevelName + ".xml");
                            File.WriteAllText(filePath, resultWriter.GetTestResult());
                        }
                        catch (Exception e)
                        {
                            Debug.LogException(e);
                        }
                    }
                    if (dto.levelCount - dto.loadedLevel == 1)
                    {
                        m_Running = false;
                        m_RunFinished = true;
                    }
                    break;
                case ResultDTO.MessageType.Ping:
                    break;
            }
        }
        private void AcceptCallback(TcpClient client)
        {
            repaint = true;
            ResultDTO dto = null;

            try
            {
                lastMessageReceived = DateTime.Now;
                using (var stream = client.GetStream())
                {
                    var bf = new BinaryFormatter();
                    dto = (ResultDTO)bf.Deserialize(stream);
                    stream.Close();
                }
                client.Close();
            }
            catch (ObjectDisposedException e)
            {
                Debug.LogException(e);
                statusLabel = "Got disconnected";
                return;
            }
            catch (Exception e)
            {
                Debug.LogException(e);
                return;
            }

            switch (dto.messageType)
            {
            case ResultDTO.MessageType.TestStarted:
                statusLabel = dto.testName;
                testTimeout = TimeSpan.FromSeconds(dto.testTimeout);
                break;

            case ResultDTO.MessageType.TestFinished:
                testResults.Add(dto.testResult);
                testTimeout = TimeSpan.Zero;
                if (dto.testResult.Executed && !dto.testResult.IsSuccess)
                {
                    testFailed = true;
                }
                break;

            case ResultDTO.MessageType.RunStarted:
                testResults = new List <ITestResult> ();
                statusLabel = "Run started: " + dto.loadedLevelName;
                break;

            case ResultDTO.MessageType.RunFinished:
                WriteResultsToLog(dto, testResults);
                if (!string.IsNullOrEmpty(configuration.resultsDir))
                {
                    var resultWriter = new XmlResultWriter(dto.loadedLevelName, testResults.ToArray());
                    try
                    {
                        var filePath = Path.Combine(configuration.resultsDir, dto.loadedLevelName + ".xml");
                        File.WriteAllText(filePath, resultWriter.GetTestResult());
                    }
                    catch (Exception e)
                    {
                        Debug.LogException(e);
                    }
                }
                if (dto.levelCount - dto.loadedLevel == 1)
                {
                    running     = false;
                    runFinished = true;
                }
                break;

            case ResultDTO.MessageType.Ping:
                break;
            }
        }