public void ShouldShowEachTestSuiteOnlyOnce()
        {
            string xml = @"<cruisecontrol><build><buildresults><target><task>
					<test-results total=""4"" failures=""1"" not-run=""3"" date=""2012-03-03"" time=""13:11:39"">
						<test-suite type=""TestFixture"" name=""Failed"" executed=""True"" result=""Failure"" success=""False""><results>
							<test-case name=""Failed.Fail"" executed=""True"" result=""Failure"" success=""False"" />
							<test-case name=""Failed.Ignore"" executed=""False"" result=""Ignored"" />
							<test-case name=""Failed.Pass"" executed=""True"" result=""Success"" success=""True"" />
						</results></test-suite>
							<test-suite type=""TestFixture"" name=""Ignored"" executed=""True"" result=""Success"" success=""True""><results>
							<test-case name=""Ignored.Ignore"" executed=""False"" result=""Ignored"" />
							<test-case name=""Ignored.Pass"" executed=""True"" result=""Success"" success=""True"" />
						</results></test-suite>
							<test-suite type=""TestFixture"" name=""IgnoredOnly"" executed=""True"" result=""Inconclusive"" success=""False""><results>
							<test-case name=""IgnoredOnly.Ignore"" executed=""False"" result=""Ignored"" />
						</results></test-suite>
							<test-suite type=""TestFixture"" name=""Passed"" executed=""True"" result=""Success"" success=""True""><results>
							<test-case name=""Passed.Pass"" executed=""True"" result=""Success"" success=""True"" />
						</results></test-suite>
					</test-results>
				</task></target></buildresults></build></cruisecontrol>"                ;

            string actualXml = LoadStylesheetAndTransformInput(xml);

            CustomAssertion.AssertMatchCount(4, @"<a name=""[^""]+"">", actualXml);
        }
Example #2
0
        public void ShouldOutputDateOfModification()
        {
            string input     = string.Format(@"<cruisecontrol>{0}</cruisecontrol>", ModificationString("2002-10-02 09:55"));
            string actualXml = LoadStylesheetAndTransformInput(input);

            CustomAssertion.AssertContains("2002-10-02 09:55", actualXml);
        }
        public void ShouldRenderErrorMessageAtTheStartOfLine()
        {
            string input = @"error CS1504: Source file 'C:\Beachball\Checkout\shared\Model\beachball-schema1.cs' could not be opened ('The system cannot find the file specified. ')";

            string actualXml = LoadStylesheetAndTransformInput(CreateInfoMessage(input));

            CustomAssertion.AssertContains("error CS1504: Source file", actualXml);
        }
        public void ShouldNotRenderRulesErrorMessage()
        {
            string input = @"* Rules gave the following errors:";

            string actualXml = LoadStylesheetAndTransformInput(CreateInfoMessage(input));

            CustomAssertion.AssertNotContains("Rules", actualXml);
        }
Example #5
0
        public void ShouldOutputIntegrationRequest()
        {
            string input = @"<cruisecontrol><request>foobar</request></cruisecontrol>";

            string actualXml = LoadStylesheetAndTransformInput(input);

            CustomAssertion.AssertContains("foobar", actualXml);
        }
        public void ShouldNotRenderBuildCompleteMessage()
        {
            string input = @"<![CDATA[ Build complete -- 1 errors, 0 warnings
  ]]>";

            string actualXml = LoadStylesheetAndTransformInput(CreateInfoMessage(input));

            CustomAssertion.AssertNotContains("Build complete", actualXml);
        }
        public void ShouldRenderWarnings()
        {
            string xml       = WrapInBuildResultsElement(@"<msbuild><warning file=""c:\temp\foo.txt"" line=""10"" column=""23"">Invalid behaviour.</warning></msbuild>");
            string actualXml = LoadStylesheetAndTransformInput(xml);

            CustomAssertion.AssertContains(@"c:\temp\foo.txt", actualXml);
            CustomAssertion.AssertContains("(10,23)", actualXml);
            CustomAssertion.AssertContains("Invalid behaviour.", actualXml);
        }
        public void ShouldRenderNAntBuildErrorElement()
        {
            string xml = string.Format(@"<cruisecontrol><build><buildresults><failure><builderror>
	<message>External Program Failed: D:\tools\cvsexe\cvswithplinkrsh.bat (return code was 1)</message>
</builderror></failure></buildresults></build></cruisecontrol>");

            string actualXml = LoadStylesheetAndTransformInput(CreateInfoMessage(xml));

            CustomAssertion.AssertContains("External Program Failed:", actualXml);
        }
        public void ShouldShowTestDetailsIfIncludingOutputFromNAnt()
        {
            string xml = @"<cruisecontrol><build><buildresults><target><task>
                    <test-results total=""6"" failures=""0"" not-run=""0"" date=""2005-04-29"" time=""9:02 PM"">
						<test-suite />
					</test-results>
				</task></target></buildresults></build></cruisecontrol>"                ;

            string actualXml = LoadStylesheetAndTransformInput(xml);

            CustomAssertion.AssertContains("6\xA0tests", actualXml);
        }
        public void VerifyPowerShellProcessInfoBasic()
        {
            ProcessInfo   info          = null;
            ProcessResult processResult = new ProcessResult("output", "error", 0, false);

            mockProcessExecutor.Setup(executor => executor.Execute(It.IsAny <ProcessInfo>())).
            Callback <ProcessInfo>(processInfo => info = processInfo).Returns(processResult).Verifiable();
            mytask.Executable = POWERSHELL_PATH;
            mytask.Script     = "MyScipt.ps1";

            mytask.Run(IntegrationResult());

            Assert.AreEqual(POWERSHELL_PATH, info.FileName);
            Assert.AreEqual(PowerShellTask.DefaultBuildTimeOut * 1000, info.TimeOut);
            CustomAssertion.AssertContains(mytask.Script, info.Arguments);
        }
        public void VerifyPowerShellProcessInfoWithScriptsDirectoryConfigured()
        {
            ProcessInfo   info          = null;
            ProcessResult processResult = new ProcessResult("output", "error", 0, false);

            mockProcessExecutor.Setup(executor => executor.Execute(It.IsAny <ProcessInfo>())).
            Callback <ProcessInfo>(processInfo => info = processInfo).Returns(processResult).Verifiable();
            mytask.Executable = POWERSHELL_PATH;
            mytask.Script     = "MyScript.ps1";
            mytask.ConfiguredScriptsDirectory = @"D:\CruiseControl";

            mytask.Run(IntegrationResult());

            Assert.AreEqual(POWERSHELL_PATH, info.FileName);
            Assert.AreEqual(PowerShellTask.DefaultBuildTimeOut * 1000, info.TimeOut);
            CustomAssertion.AssertStartsWith(@"-nologo -NoProfile -NonInteractive -file ""D:\CruiseControl\MyScript.ps1""", info.Arguments);
        }
        public void ShouldRenderTotalTestsWhenAllTestsPass()
        {
            string xml       = WrapInTestsElement(@"<TestRun type=""Microsoft.VisualStudio.TestTools.Common.TestRun"">
<result type=""Microsoft.VisualStudio.TestTools.Common.RunResultAndStatistics"">
  <totalTestCount type=""System.Int32"">29</totalTestCount> 
  <executedTestCount type=""System.Int32"">29</executedTestCount> 
  <passedTestCount type=""System.Int32"">29</passedTestCount> 
</result></TestRun>");
            string actualXml = LoadStylesheetAndTransformInput(xml);

            Console.Out.WriteLine("actualXml = {0}", actualXml);
            CustomAssertion.AssertContains("Tests run: 29", actualXml);
            CustomAssertion.AssertContains("Failures: 0", actualXml);
            CustomAssertion.AssertContains("Not run: 0", actualXml);
            CustomAssertion.AssertContains("All tests passed.", actualXml);
            CustomAssertion.AssertNotContains("FooTest", actualXml);
        }
Example #13
0
        public void AnalyzeModifications()
        {
            Modification[] expected = new Modification[1];
            expected[0]              = new Modification();
            expected[0].Comment      = @"Added new labels.";
            expected[0].EmailAddress = null;
            expected[0].Version      = "1.4";
            expected[0].FileName     = @"ChessViewer.java-arc";
            expected[0].FolderName   = @"D:\root\PVCS\vm\common\SampleDB\archives\chess\client";
            expected[0].ModifiedTime = DateTime.Parse("2/1/00 4:52:46 PM", dfi);
            expected[0].Type         = "Checked in";
            expected[0].UserName     = "******";

            Modification[] actual = PvcsHistoryParser.AnalyzeModifications(GetExpectedModificationsForAnalyze());

            CustomAssertion.AssertEqualArrays(actual, expected);
        }
        public void VerifyPowerShellProcessInfoBasic()
        {
            CollectingConstraint constraint    = new CollectingConstraint();
            ProcessResult        processResult = new ProcessResult("output", "error", 0, false);

            mockProcessExecutor.ExpectAndReturn("Execute", processResult, new object[] { constraint });
            mytask.Executable = POWERSHELL_PATH;
            mytask.Script     = "MyScipt.ps1";

            mytask.Run(IntegrationResult());

            ProcessInfo info = (ProcessInfo)constraint.Parameter;

            Assert.AreEqual(POWERSHELL_PATH, info.FileName);
            Assert.AreEqual(PowerShellTask.DefaultBuildTimeOut * 1000, info.TimeOut);
            CustomAssertion.AssertContains(mytask.Script, info.Arguments);
        }
        public void ShouldRenderNAntInternalErrorElement()
        {
            string xml = string.Format(@"<cruisecontrol><build><buildresults><failure><internalerror>
      <type>System.IO.FileNotFoundException</type>
      <message><![CDATA[Could not load file or assembly 'nunit.core, Version=2.2.0.0, Culture=neutral, PublicKeyToken=96d09a1eb7f44a77' or one of its dependencies. The system cannot find the file specified.]]></message>
      <stacktrace><![CDATA[   at NAnt.NUnit2.Tasks.NUnit2Task.ExecuteTask()
   at NAnt.Core.Task.Execute()
   at NAnt.Core.Target.Execute()
   at NAnt.Core.Project.Execute(String targetName, Boolean forceDependencies)
   at NAnt.Core.Project.Execute()
   at NAnt.Core.Project.Run()]]></stacktrace>
    </internalerror></failure></buildresults></build></cruisecontrol>");

            string actualXml = LoadStylesheetAndTransformInput(CreateInfoMessage(xml));

            CustomAssertion.AssertContains("Could not load file or assembly 'nunit.core", actualXml);
        }
        public void VerifyPowerShellProcessInfoWithScriptsDirectoryConfigured()
        {
            CollectingConstraint constraint    = new CollectingConstraint();
            ProcessResult        processResult = new ProcessResult("output", "error", 0, false);

            mockProcessExecutor.ExpectAndReturn("Execute", processResult, new object[] { constraint });
            mytask.Executable = POWERSHELL_PATH;
            mytask.Script     = "MyScript.ps1";
            mytask.ConfiguredScriptsDirectory = @"D:\CruiseControl";

            mytask.Run(IntegrationResult());

            ProcessInfo info = (ProcessInfo)constraint.Parameter;

            Assert.AreEqual(POWERSHELL_PATH, info.FileName);
            Assert.AreEqual(PowerShellTask.DefaultBuildTimeOut * 1000, info.TimeOut);
            CustomAssertion.AssertStartsWith(@"-nologo -NoProfile -NonInteractive -file ""D:\CruiseControl\MyScript.ps1""", info.Arguments);
        }
        public void ShouldRenderFailedTests()
        {
            string xml       = WrapInTestsElement(@"<TestRun type=""Microsoft.VisualStudio.TestTools.Common.TestRun"">
<result type=""Microsoft.VisualStudio.TestTools.Common.RunResultAndStatistics"">
  <totalTestCount type=""System.Int32"">29</totalTestCount> 
  <executedTestCount type=""System.Int32"">28</executedTestCount> 
  <passedTestCount type=""System.Int32"">27</passedTestCount> 
</result></TestRun>
<UnitTestResult type=""Microsoft.VisualStudio.TestTools.TestTypes.Unit.UnitTestResult, Microsoft.VisualStudio.QualityTools.Tips.UnitTest.ObjectModel, Version=8.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"">
	<outcome type=""Microsoft.VisualStudio.TestTools.Common.TestOutcome"">
		<value__ type=""System.Int32"">1</value__>
	</outcome>
	<errorInfo type=""Microsoft.VisualStudio.TestTools.Common.TestResultErrorInfo"">
		<message type=""System.String"">
		Test method Com.Suncor.Olt.Common.DataAccess.DatabaseGatewayTest.ShouldNotAcceptWrongNumberOfParameters threw exception:  System.ApplicationException: Received 7 parameters for InsertFoo, expected 1.
		</message>
		<stackTrace type=""System.String"">
    at Com.Suncor.Olt.Common.DataAccess.DatabaseGateway.CheckNumberOfInputParameters(IDbCommand command, String procedureName, Object[] parameters) in C:\Projects\OLT\src\Common\App\DataAccess\DatabaseGateway.cs:line 148
   at Com.Suncor.Olt.Common.DataAccess.DatabaseGateway.ExecuteNonQuery(String procedureName, Object[] parameters) in C:\Projects\OLT\src\Common\App\DataAccess\DatabaseGateway.cs:line 78
   at Com.Suncor.Olt.Common.DataAccess.DatabaseGatewayTest.ShouldNotAcceptWrongNumberOfParameters() in C:\Projects\OLT\src\Common\Test.UnitTest\DataAccess\DatabaseGatewayTest.cs:line 90
		</stackTrace>
	</errorInfo>
	<testName type=""System.String"">ShouldNotAcceptWrongNumberOfParameters</testName>
</UnitTestResult>
<UnitTestResult type=""Microsoft.VisualStudio.TestTools.TestTypes.Unit.UnitTestResult, Microsoft.VisualStudio.QualityTools.Tips.UnitTest.ObjectModel, Version=8.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"">
	<outcome type=""Microsoft.VisualStudio.TestTools.Common.TestOutcome"">
		<value__ type=""System.Int32"">10</value__>
	</outcome>
	<testName type=""System.String"">FooTest</testName>
</UnitTestResult>");
            string actualXml = LoadStylesheetAndTransformInput(xml);

            CustomAssertion.AssertContains("Tests run: 28", actualXml);
            CustomAssertion.AssertContains("Failures: 1", actualXml);
            CustomAssertion.AssertContains("Not run: 1", actualXml);
            CustomAssertion.AssertNotContains("All tests passed.", actualXml);
            CustomAssertion.AssertContains("ShouldNotAcceptWrongNumberOfParameters", actualXml);
            CustomAssertion.AssertContains("System.ApplicationException", actualXml);
            CustomAssertion.AssertContains("Stacktrace", actualXml);
            CustomAssertion.AssertNotContains("FooTest", actualXml);
        }
        public void ShouldSetOutputAndIntegrationStatusToFailedOnFailedBuild()
        {
            ProcessResult processResult = new ProcessResult(@"Documents\WindowsPowerShell\MyScript.ps1' is not recognized as a cmdlet", string.Empty, 1, false);
            ProcessInfo   info          = null;

            mockProcessExecutor.Setup(executor => executor.Execute(It.IsAny <ProcessInfo>())).
            Callback <ProcessInfo>(processInfo => info = processInfo).Returns(processResult).Verifiable();

            mytask.Executable = POWERSHELL_PATH;
            mytask.Script     = "MyScript.ps1";
            mytask.ConfiguredScriptsDirectory = @"D:\CruiseControl";

            IIntegrationResult result = Integration("myProject", @"D:\CruiseControl", "myArtifactDirectory");

            mytask.Run(result);

            Assert.AreEqual(@"D:\CruiseControl", info.WorkingDirectory);

            Assert.AreEqual(IntegrationStatus.Failure, result.Status);
            CustomAssertion.AssertMatches(@"(\.|\n)*is not recognized as a cmdlet", result.TaskOutput);
        }
        public void ShouldSetOutputAndIntegrationStatusToFailedOnFailedBuild()
        {
            ProcessResult        processResult = new ProcessResult(@"Documents\WindowsPowerShell\MyScript.ps1' is not recognized as a cmdlet", string.Empty, 1, false);
            CollectingConstraint constraint    = new CollectingConstraint();

            mockProcessExecutor.ExpectAndReturn("Execute", processResult, new object[] { constraint });

            mytask.Executable = POWERSHELL_PATH;
            mytask.Script     = "MyScript.ps1";
            mytask.ConfiguredScriptsDirectory = @"D:\CruiseControl";

            IIntegrationResult result = Integration("myProject", @"D:\CruiseControl", "myArtifactDirectory");

            mytask.Run(result);

            ProcessInfo info = (ProcessInfo)constraint.Parameter;

            Assert.AreEqual(@"D:\CruiseControl", info.WorkingDirectory);

            Assert.AreEqual(IntegrationStatus.Failure, result.Status);
            CustomAssertion.AssertMatches(@"(\.|\n)*is not recognized as a cmdlet", result.TaskOutput);
        }
        public void ShouldSetOutputAndIntegrationStatusToSuccessOnSuccessfulBuild()
        {
            ProcessResult processResult = new ProcessResult(" ", string.Empty, ProcessResult.SUCCESSFUL_EXIT_CODE, false);

            mockProcessExecutor.Setup(executor => executor.Execute(It.IsAny <ProcessInfo>())).Returns(processResult).Verifiable();
            mytask.Executable           = POWERSHELL_PATH;
            mytask.Script               = "MyScript.ps1";
            mytask.BuildArgs            = "an arg";
            mytask.EnvironmentVariables = new EnvironmentVariable[]
            {
                new EnvironmentVariable
                {
                    name  = "test",
                    value = "value"
                }
            };

            IntegrationResult result = (IntegrationResult)IntegrationResult();

            mytask.Run(result);

            Assert.AreEqual(IntegrationStatus.Success, result.Status);
            CustomAssertion.AssertMatches(" ", result.TaskOutput);
        }
Example #21
0
 public void ParseModifications()
 {
     Modification[] actual   = parser.Parse(ContentReader, OLDEST_ENTRY, NEWEST_ENTRY);
     Modification[] expected = GetExpectedModifications();
     CustomAssertion.AssertEqualArrays(expected, actual);
 }