Developing your own user-scripted C# bundle harness action

TestArchitect provides sample C# bundle harness code files for you to learn to develop, build, and execute C#-scripted actions.

The following list provides an introductory overview of C# bundle harness folders and files provided with the installation of TestArchitect.

Notes: 
  1. csharp: Root directory of the C# bundle harness sample.
  2. source: Contains source code of C# user-scripted actions
  3. executables: Folder containing C# harness executable files and supporting *.DLL file.
    1. bundles: Contains *.DLL files of C# user-scripted actions.

    2. Interop.TestArchitect.dll: a TestArchitect-C# bundle harness library. This library contains interpreter functions necessary when executing C#-scripted actions in TestArchitect.

    3. TestArchitect.Harness.Bundle.Core.dll: Exposes classes and attributes used by the C# bundle harness.

      • The following custom attributes are provided.

        Custom attributeDescription
        ActionClassDefinitionAttribute- Announce that a given class contains user-scripted action’s code implementation
        ActionDefinitionAttribute- Mark that the method is mapped to a specific user-scripted action
        - Define a user-scripted action name and its arguments
        AssemblyHarnessBundleAttribute- Specify that this module (assembly) is a C# bundle harness
        - Provide bundle information including bundle name, bundle version, etc.
        - Defined under the /Properties/AssemblyInfo.cs
      • Also, this DLL exposes additional custom attributes to trigger test run, action, test case, and test module events.

        • Test case event:

          • BeginTestCase: Specifies the method to be called before a given test case is executed.

            [BeginTestCase]
            public void BeginTestCase()
            {
              //do something
            }
            
          • EndTestCase: Specifies the method to be called after a given test case is executed.

            [EndTestCase]
            public void EndTestCase()
            {
              //do something
            }
            
          • TestCaseContext: Provides data for a given test case event. It is applicable for both BeginTestCase and EndTestCase.

            [BeginTestCase]
            public void BeginTestCase(TestCaseContext context)
            {
              //do something
            }
            
            [EndTestCase]
            public void EndTestCase(TestCaseContext context)
            {
              //do something
            }
            
        • Test module event:

          • BeginTestModule: Specifies the method to be called before a given test module is executed.

            [BeginTestModule]
            public void BeginTestModule()
            {
            //do something
            }
            
          • EndTestModule: Specifies the method to be called after a given test module is executed.

            [EndTestModule]
            public void EndTestModule()
            {
            //do something
            }
            
          • TestModuleContext: Provides data for a given test case event. It is applicable for both BeginTestModule and EndTestModule.

            [BeginTestModule]
            public void BeginTestModule(TestModuleContext context)
            {
             //do something
            }    
            
            [EndTestModule]
            public void EndTestModule(TestModuleContext context)
            {
             //do something
            } 
            
        • Action event:

          • BeginAction: Specifies the method to be called before a given action is executed.

            [BeginAction]
            public void BeginAction()
            {
              //do something
            }
            
          • EndAction: Specifies the method to be called after a given action is executed.

            [EndAction]
            public void EndAction()
            {
              //do something
            }
            
          • ActionContext: Provides data for a given test case event. It is applicable for both BeginAction and EndAction.

            [BeginAction]
            public void BeginAction(ActionContext context)
            {
              //do something
            }
            
            [EndAction]
            public void EndAction(ActionContext context)
            {
              //do something
            }
            
        • Test run event:

          • BeginRun: Specifies the method to be called after a given test run is executed.

            [BeginRun]
            public void BeginRun()
            {
              //do something
            }
            
          • EndRun: Specifies the method to be called after a given test run is executed.

            [EndRun]
            public void EndRun()
            {
              //do something
            }
            
          • TestRunContext: Provides data for a given test run event. It is applicable for both BeginRun and EndRun.

            [BeginRun]
            public void BeginRun(TestRunContext context)
            {
              //do something
            }
            
            [EndRun]
            public void EndRun(TestRunContext context)
            {
              //do something
            }
            
    4. TestArchitect.Harness.Executor.exe:

      • Loads DLLs of C# bundle harness.
      • Controls actions flow, that is, parses harness action and diverts it to the implementation code.

Rules to create a new user-scripted action in a new C# class

Creating a new user-scripted action in a new C# class in the bundle harness involves these steps:

  1. Create a new C# class to store the function definition for action.
  2. Add the ActionClassDefinition attribute to inform that this class contains action implementation.
  3. Create a function definition that provides the actual action-specific logic.
  4. Add the ActionDefinition attribute to mark the to-be-implemented function to map to a given user-scripted action.
  5. Define action name and argument names of the user-scripted action by using the ActionName and Arguments attribute properties, respectively.

Rules to add a new user-scripted action to an existing C# class

Add a new user-scripted action to an already existing C# class in the bundle harness involves these steps:

  1. Create a function definition that provides the actual action-specific logic.
  2. Add the ActionDefinition attribute to mark the to-be-implemented function to map to a given user-scripted action.
  3. Define action name and argument names of the user-scripted action by using the ActionName and Arguments attribute properties, respectively.

Important notes to build bundle harness DLLs and deploy dependencies


Copyright © 2024 LogiGear Corporation. All rights reserved. LogiGear is a registered trademark, and Action Based Testing and TestArchitect are trademarks of LogiGear Corporation. All other trademarks contained herein are the property of their respective owners.

LogiGear Corporation

1730 S. Amphlett Blvd. Suite 200, San Mateo, CA 94402

Tel: +1 (650) 572-1400