private static TestSuites Run(tSQLtTestRunner testSession, TestCase test) { if (test != null && test.DisplayName != null && test.DisplayName.Contains(".")) { return(testSession.Run(test.DisplayName.Split('.')[0], test.DisplayName.Split('.')[1])); } return(null); }
public void RunTests(IEnumerable <TestCase> tests, IRunContext runContext, IFrameworkHandle frameworkHandle) { m_cancelled = false; var connectionString = new RunSettings(runContext.RunSettings).GetSetting("TestDatabaseConnectionString"); if (String.IsNullOrEmpty(connectionString)) { frameworkHandle.SendMessage(TestMessageLevel.Error, @"No connection string found. You need to specify a run setting with the name ""TestDatabaseConnectionString"". Create a .runsettings file a sample is: <?xml version=""1.0"" encoding=""utf-8""?> <RunSettings> <!-- Parameters used by tests at runtime --> <TestRunParameters> <Parameter name=""TestDatabaseConnectionString"" value=""server=Servername;initial catalog=UnitTestDatabase;integrated security=sspi"" /> <!-- If you have a large project then to speed up discovery, use this to limit which .sql files are parsed. If all your tests are in a subfolder called \UnitTests\ or \Our-UnitTests\ then set the value to UnitTests - it is a regex so U.i.T.s.s will also work. <!-- <Parameter name=""IncludePath"" value=""RegexToTestsToInclude"" /> --> </TestRunParameters> </RunSettings> If you are running tests in visual studio choose ""Test-->Test Settings-->Select Test Settings File--> Choose your .runsettings file"", if you are using the command line pass the runsettings files using /Settings:PathTo.runsettings "); return; } foreach (TestCase test in tests) { if (m_cancelled) { break; } var testResult = new TestResult(test); var testSession = new tSQLtTestRunner(connectionString); var result = Run(testSession, test); if (null == result) { continue; } testResult.Outcome = result.Passed() ? TestOutcome.Passed : TestOutcome.Failed; testResult.ErrorMessage += result.FailureMessages(); frameworkHandle.RecordResult(testResult); } }
public void exceptions_in_the_gateway_result_in_errors_being_returned() { const string expected_format = "exec tSQLtTestRunner.RunWithXmlResults [{0}].[{1}]"; const string className = "this is the class"; const string testName = "testipoos blah blah"; string expected = string.Format(expected_format, className, testName); var gateway = new Mock<ISqlServerGateway>(); gateway.Setup(p => p.RunWithXmlResult(It.IsAny<string>())).Returns<string>((query) => { throw new InvalidOperationException("blah blah blah"); }); var tester = new tSQLtTestRunner(gateway.Object); var result = tester.Run(className, testName); Assert.IsFalse(result.Passed()); }
public void exceptions_in_the_gateway_result_in_errors_being_returned() { const string expected_format = "exec tSQLtTestRunner.RunWithXmlResults [{0}].[{1}]"; const string className = "this is the class"; const string testName = "testipoos blah blah"; string expected = string.Format(expected_format, className, testName); var gateway = new Mock <ISqlServerGateway>(); gateway.Setup(p => p.RunWithXmlResult(It.IsAny <string>())).Returns <string>((query) => { throw new InvalidOperationException("blah blah blah"); }); var tester = new tSQLtTestRunner(gateway.Object); var result = tester.Run(className, testName); Assert.IsFalse(result.Passed()); }
public void single_test_runs_query_with_xml_results() { const string expected_format = "exec tSQLtTestRunner.RunWithXmlResults [{0}].[{1}]"; const string className = "this is the class"; const string testName = "testipoos blah blah"; string expected = string.Format(expected_format, className, testName); var gateway = new Mock<ISqlServerGateway>(); gateway.Setup(p => p.RunWithXmlResult(It.IsAny<string>())).Returns<string>((query) => { Assert.AreEqual(expected, query); return DefaultXml; }); var tester = new tSQLtTestRunner(gateway.Object); var result = tester.Run(className, testName); Assert.AreEqual(1, result.TestCount()); }
public void single_test_runs_query_with_xml_results() { const string expected_format = "exec tSQLtTestRunner.RunWithXmlResults [{0}].[{1}]"; const string className = "this is the class"; const string testName = "testipoos blah blah"; string expected = string.Format(expected_format, className, testName); var gateway = new Mock <ISqlServerGateway>(); gateway.Setup(p => p.RunWithXmlResult(It.IsAny <string>())).Returns <string>((query) => { Assert.AreEqual(expected, query); return(DefaultXml); }); var tester = new tSQLtTestRunner(gateway.Object); var result = tester.Run(className, testName); Assert.AreEqual(1, result.TestCount()); }
public DummyTests() { _connString = ConfigurationManager.ConnectionStrings["tSQLt"].ConnectionString; _runner = new tSQLtTestRunner(_connString); }