Example #1
0
 /// <summary>
 /// Adds metadata to the step that is running in the context.
 /// </summary>
 /// <param name="metadataKey">The metadata key.</param>
 /// <param name="metadataValue">The metadata value.</param>
 /// <exception cref="ArgumentNullException">Thrown if <paramref name="metadataKey"/>
 /// or <paramref name="metadataValue"/> is null.</exception>
 /// <exception cref="InvalidOperationException">Thrown if there is no current test context.</exception>
 public static void AddMetadata(string metadataKey, string metadataValue)
 {
     TestContext.GetCurrentContextOrThrow().AddMetadata(metadataKey, metadataValue);
 }
Example #2
0
 /// <summary>
 /// Performs an action as a new step within the current context and associates it
 /// with the specified code reference.  Verifies that the step produced the expected outcome.
 /// </summary>
 /// <remarks>
 /// <para>
 /// This method creates a new child context with a new nested <see cref="Model.Tree.TestStep" />,
 /// enters the child context, performs the action, then exits the child context.
 /// </para>
 /// <para>
 /// This method may be called recursively to create nested steps or concurrently
 /// to create parallel steps.
 /// </para>
 /// <para>
 /// This method verifies that the step produced the expected outcome.  If a different outcome
 /// was obtained, then raises an assertion failure.
 /// </para>
 /// </remarks>
 /// <param name="name">The name of the step.</param>
 /// <param name="action">The action to perform.</param>
 /// <param name="timeout">The step execution timeout, or null if none.</param>
 /// <param name="isTestCase">True if the step represents an independent test case.</param>
 /// <param name="codeElement">The associated code element, or null if none.</param>
 /// <param name="expectedOutcome">The expected outcome of the step.</param>
 /// <returns>The context of the step that ran.</returns>
 /// <exception cref="ArgumentNullException">Thrown if <paramref name="name"/> or
 /// <paramref name="action"/> is null.</exception>
 /// <exception cref="ArgumentException">Thrown if <paramref name="name"/> is the empty string.</exception>
 /// <exception cref="ArgumentOutOfRangeException">Thrown if <paramref name="timeout"/> is negative.</exception>
 /// <exception cref="AssertionFailureException">Thrown if the expected outcome was not obtained.</exception>
 /// <exception cref="InvalidOperationException">Thrown if there is no current test context.</exception>
 public static TestContext RunStepAndVerifyOutcome(string name, Action action, TimeSpan?timeout, bool isTestCase, ICodeElementInfo codeElement, TestOutcome expectedOutcome)
 {
     return(TestContext.GetCurrentContextOrThrow().RunStepAndVerifyOutcome(name, action, timeout, isTestCase, codeElement, expectedOutcome));
 }
Example #3
0
 public static TestContext RunStepAndVerifyOutcome(string name, Action action, TimeSpan?timeout, TestOutcome expectedOutcome)
 {
     return(TestContext.GetCurrentContextOrThrow().RunStepAndVerifyOutcome(name, action, timeout, false, Reflector.GetCallingFunction(), expectedOutcome));
 }
Example #4
0
 /// <summary>
 /// Performs an action as a new step within the current context and associates it
 /// with the specified code reference.  Does not verify the outcome of the step.
 /// </summary>
 /// <remarks>
 /// <para>
 /// This method creates a new child context with a new nested <see cref="Model.Tree.TestStep" />,
 /// enters the child context, performs the action, then exits the child context.
 /// </para>
 /// <para>
 /// This method may be called recursively to create nested steps or concurrently
 /// to create parallel steps.
 /// </para>
 /// <para>
 /// This method does not verify that the test step completed successfully.  Check the
 /// <see cref="TestContext.Outcome" /> of the test step or call <see cref="RunStepAndVerifyOutcome(string, Action, TimeSpan?, bool, ICodeElementInfo, TestOutcome)"/>
 /// to ensure that the expected outcome was obtained.
 /// </para>
 /// </remarks>
 /// <param name="name">The name of the step.</param>
 /// <param name="action">The action to perform.</param>
 /// <param name="timeout">The step execution timeout, or null if none.</param>
 /// <param name="isTestCase">True if the step represents an independent test case.</param>
 /// <param name="codeElement">The associated code element, or null if none.</param>
 /// <returns>The context of the step that ran.</returns>
 /// <exception cref="ArgumentNullException">Thrown if <paramref name="name"/> or
 /// <paramref name="action"/> is null.</exception>
 /// <exception cref="ArgumentException">Thrown if <paramref name="name"/> is the empty string.</exception>
 /// <exception cref="ArgumentOutOfRangeException">Thrown if <paramref name="timeout"/> is negative.</exception>
 /// <exception cref="InvalidOperationException">Thrown if there is no current test context.</exception>
 public static TestContext RunStep(string name, Action action, TimeSpan?timeout, bool isTestCase, ICodeElementInfo codeElement)
 {
     return(TestContext.GetCurrentContextOrThrow().RunStep(name, action, timeout, isTestCase, codeElement));
 }
Example #5
0
 public static TestContext RunStep(string name, Action action, TimeSpan?timeout)
 {
     return(TestContext.GetCurrentContextOrThrow().RunStep(name, action, timeout, false, Reflector.GetCallingFunction()));
 }
Example #6
0
 public static TestContext RunStep(string name, GallioAction action)
 {
     return(TestContext.GetCurrentContextOrThrow().RunStep(name, action, null, false, Reflector.GetCallingFunction()));
 }