Executing a Simple Test Suite Prerequisites:

  • Updated

Prerequisites: A valid test suite
Namespaces: InRule.Runtime, InRule.Runtime.Testing.Regression, InRule.Runtime.Testing.Session
Classes: TestSuiteDef, TestResultCollection, TestingSessionManager, RegressionTestingSession
See Also: Authoring a Simple Test Suite for Regression Testing

The key points in the below code sample, are that the TestingSessionManager should be used with a using() pattern to ensure it is disposed when testing is finished.  This ensures any lingering RuleSessions are also disposed correctly.

public static void ExecuteSimpleTestSuite()
 // Get the TestSuitePersistenceProvider from the file system
 TestSuitePersistenceProvider testProvider =
new ZipFileTestSuitePersistenceProvider(@"C:\Temp\SimpleTestSuite.testsuite");

 // Load the TestSuiteDef using the provider
 TestSuiteDef suite = TestSuiteDef.LoadFrom(testProvider);

 // Load the rule application into the test suite
 suite.ActiveRuleApplicationDef = RuleApplicationDef.Load(@"C:\Temp\SimpleRuleApp.ruleapp");

 // Set up a testing manager with an InProcessConnection factory
 using (TestingSessionManager manager =
new TestingSessionManager(new InProcessConnectionFactory()))

         // Create the testing session
         RegressionTestingSession session = new RegressionTestingSession(manager, suite);

         // Execute all Tests in the Test Suite - Ensure results collection is disposed
         using (TestResultCollection results = session.ExecuteAllTests())

                 // Persist TestResults to the file system

                 // Output result information
                 Console.WriteLine("{0} Test(s) executed.", results.Count);
                 Console.WriteLine("TestResult 1 {0}.", results[0].Passed ? "passed" : "failed");
                 Console.WriteLine("TestResult 1 execution duration: {0}.", results[0].Duration);
                 Console.WriteLine("TestResult 1, Assertion 1 Expected Value: {0}.",
                 Console.WriteLine("TestResult 1, Assertion 1 Actual Value: {0}.",
                 Console.WriteLine("TestResult 1, Assertion 1 Target: {0}.", results[0].AssertionResults[0].Target);
                 Console.WriteLine("TestResult 1, Assertion 1 Display Text: {0}.",

The output looks like the following:

1 Test(s) executed.
TestResult 1 passed.
TestResult 1 execution duration: 00:00:00.2921900.
TestResult 1, Assertion 1 Expected Value: 7.
TestResult 1, Assertion 1 Actual Value: 7.
TestResult 1, Assertion 1 Target: Field2.
TestResult 1, Assertion 1 Display Text: Field2 is equal to 7

Was this article helpful?

0 out of 0 found this helpful



Please sign in to leave a comment.