Ejemplo n.º 1
0
        public void ListParser_ParseNull()
        {
            var testCases = new List<ITestCase>();
            ITestSuite mockSuite = CreateMockTestSuite(testCases);
            var parserUnderTest = CreateParserUnderTest(mockSuite);
            var parserValidator = new ParserValidator(parserUnderTest);

            Assert.DoesNotThrow(() =>
                parserUnderTest.ParseLine(null));
        }
Ejemplo n.º 2
0
        public void ListParser_ParseTestCase()
        {
            var testCases = new List<ITestCase>();
            ITestSuite mockSuite = CreateMockTestSuite(testCases);
            var parserUnderTest = CreateParserUnderTest(mockSuite);
            var parserValidator = new ParserValidator(parserUnderTest);

            parserUnderTest.ParseLine("TestCase.");

            Assert.AreEqual(1, testCases.Count());
            Assert.False(parserValidator.TestDiscovered);
        }
Ejemplo n.º 3
0
        public void ListParser_Discover()
        {
            var testCases = new List<ITestCase>();
            ITestSuite mockSuite = CreateMockTestSuite(testCases);
            var parserUnderTest = CreateParserUnderTest(mockSuite);
            var parserValidator = new ParserValidator(parserUnderTest);

            parserUnderTest.ParseLine("TestCase.");
            parserUnderTest.ParseLine("  Test");

            Assert.True(parserValidator.TestDiscovered);
        }
Ejemplo n.º 4
0
        public void ParseLine_OK_RaisesFinishedEventWithPassedResult()
        {
            ITestSuite suite;
            CreateMockSuite(out suite);
            var parserUnderTest = new GTestRunOutputParser(suite, new Mock<ITestLogger>().Object);
            ParserValidator validator = new ParserValidator(parserUnderTest);

            parserUnderTest.ParseLine("[       OK ] Test.Test (10ms)");

            Assert.True(validator.TestFinished);
            Assert.NotNull(validator.FinishResult);
            Assert.AreEqual(TestStatus.Passed, validator.FinishResult.Outcome);
        }
Ejemplo n.º 5
0
        public void ParseLine_FAILED_TestWithParams_RaisesFinishedEventWithFailedResult()
        {
            ITestSuite suite;
            CreateMockSuite(out suite);
            var parserUnderTest = new GTestRunOutputParser(suite, new Mock<ITestLogger>().Object);
            ParserValidator validator = new ParserValidator(parserUnderTest);

            parserUnderTest.ParseLine("[  FAILED  ] Test.Test, where GetParam() = \"Test\" (10 ms)");

            Assert.True(validator.TestFinished);
            Assert.NotNull(validator.FinishResult);
            Assert.AreEqual(TestStatus.Failed, validator.FinishResult.Outcome);
        }
Ejemplo n.º 6
0
        public void ListParser_ParameterizedTestWithEllipsis()
        {
            var testCases = new List<ITestCase>();
            ITestSuite mockSuite = CreateMockTestSuite(testCases);
            var parserUnderTest = CreateParserUnderTest(mockSuite);
            var parserValidator = new ParserValidator(parserUnderTest);

            parserUnderTest.ParseLine("Unit_Test/Unit_Test.");
            parserUnderTest.ParseLine("  testName/0  # GetParam() = When a test param is really long it gets truncated and ellipsized like this ...");

            Assert.True(parserValidator.TestDiscovered);
            Assert.AreEqual("Unit_Test/Unit_Test.testName/0", parserValidator.DiscoveredTest.FullyQualifiedName);
        }
Ejemplo n.º 7
0
        public void ParseLine_FAILED_EndResult_RaisesNoEvents()
        {
            ITestSuite suite;
            CreateMockSuite(out suite);
            var parserUnderTest = new GTestRunOutputParser(suite, new Mock<ITestLogger>().Object);
            ParserValidator validator = new ParserValidator(parserUnderTest);

            parserUnderTest.ParseLine("[  FAILED  ] 1 test, listed below:");
            parserUnderTest.ParseLine("[  FAILED  ] Test.Test");

            Assert.False(validator.TestDiscovered);
            Assert.False(validator.TestStarted);
            Assert.False(validator.TestFinished);
        }
Ejemplo n.º 8
0
        public void ListParser_ParseMultipleTestCases()
        {
            var testCases = new List<ITestCase>();
            ITestSuite mockSuite = CreateMockTestSuite(testCases);
            var parserUnderTest = CreateParserUnderTest(mockSuite);
            var parserValidator = new ParserValidator(parserUnderTest);

            parserUnderTest.ParseLine("TestCase1.");
            parserUnderTest.ParseLine("  Test");
            parserUnderTest.ParseLine("TestCase2.");
            parserUnderTest.ParseLine("  Test");

            Assert.AreEqual(2, testCases.Count());
        }
Ejemplo n.º 9
0
        public void ParseLine_RUN_RaisesTestStartedEvent()
        {
            ITestSuite suite;
            CreateMockSuite(out suite);
            var parserUnderTest = new GTestRunOutputParser(suite, new Mock<ITestLogger>().Object);
            ParserValidator validator = new ParserValidator(parserUnderTest);

            parserUnderTest.ParseLine("[ RUN      ] Test.Test");

            Assert.True(validator.TestStarted);
        }
Ejemplo n.º 10
0
        public void ListParser_TypeParameterizedTestCase()
        {
            var testCases = new List<ITestCase>();
            ITestSuite mockSuite = CreateMockTestSuite(testCases);
            var parserUnderTest = CreateParserUnderTest(mockSuite);
            var parserValidator = new ParserValidator(parserUnderTest);

            parserUnderTest.ParseLine("TestWithParticularType/TestWithTypeParam/0.  # TypeParam = class some::namespace::TestType");
            parserUnderTest.ParseLine("  Test");

            Assert.True(parserValidator.TestDiscovered);
            Assert.AreEqual("TestWithParticularType/TestWithTypeParam/0.Test", parserValidator.DiscoveredTest.FullyQualifiedName);
        }