New to Telerik Test Studio? Download free 30-day trial

Features in Code

Test Studio Dev allows you to implement coded solutions for a scenario that requires more complexity than what can be composed with recording your actions and building advanced steps with the Step Builder. There are few ways you could proceed implementing custom code in a Test Studio Dev test and these are described below.

Coded Step

Test Studio Dev supports coded steps. This allows you to write code and have it executed as a test step. Use a coded step for a scenario where you need to extend the recorded steps functionality.

1.  Add a coded step from the Step Builder under the Common section.

Add a coded step

Inserting the first Coded step in a test automatically generates a code behind file for the current test and opens it ready for editing.

Code Behind File

Each next coded step allows you to choose whether to reuse any of the existing methods in the class or create a new one. Each existing and valid method in the code behind could be assigned to a coded step in the test.

Map Coded Step

Note! To actually execute the implemented code you have to bind the test method to an existing coded step in the test. A single method can be called from multiple steps in the test.

Convert Step in Code

Almost each recorded step could be edited in code from the Step Context menu. The steps which could not be converted because of their specifics are dialog handling steps, all condition steps (if...else, loop, while) and the Manual step and Inspection Point step in the Common section of the Step Builder.

Convert step into code

This will generate a code-behind file (if this is the first coded step for the test) or will add a new method to the already existing code-behind file. The method for a recorded step will contain the required actions in code to execute all actions for the step.

Code Behind File

The code-behind file is automatically generated when a coded step is inserted in a test. A plain code behind file (without inserted methods) can be generated by clicking the Add Code Behind File button.

Add Code Behind File

The code-behind file is nested under the parent test in Solution Explorer:

Code Behind File

A code behind file can be generated for each test where you need to implement coded steps and custom test classes. That coded file and its methods are related to the particular test.

  • the code behind file uses the respective test name as its name
  • its namespace is the project name
  • the class which contains the methods is named with the test name
  • each method uses the respective step name (if generated when inserting a coded step or converting a step to code)

Custom code

You can implement any custom logic organized in standalone code files located in your project. This includes but is not limited to classes and functions which perform common or often re-used functionality and can be called by your coded steps or code behind methods. The only requirement is to define classes in the project namespace else they will not be accessible.

In this article