Test Case structure

Overview

Once you open your newly created test case you will find several tags present within the file. All of those tags are explained within this chapter. You will also find the details of the ITester interface (engine and execution access).

Example Test Case
using System;
using Progile.ATE.Common;
using Progile.ATE.TestFramework;
//using Example_Model;

namespace TC001_Rev1
{
    [TestCase(1)]
    public class MyFirstTestCase
    {
        //  reference the software model
        //  private ExampleApp App { get; set; }

        [SetupTest]
        public bool Setup(ITester t)
        {
            //App = new ExampleApp(t);
            return true;
        }

        [PreconditionStep]
        public void PreconditionStep(ITester t)
        {
            // Example for usage of software model:
            //App.ExampleScreen.WaitFor();
            //App.ExampleScreen.ExampleAction("superuser", "safePW");

            t.Report.FailStep("REPLACE_OR_DELETE_ME");
            t.Testee.Mouse.Click(text: "Google Search");
        }

        [TestStep(1,
            TestInput = "TestInput1",
            ExpectedResults = "Expected1")]
        public void Step1(ITester t)
        {
            t.Report.FailStep("REPLACE_ME");
        }

        [CleanupStep]
        public void CleanupStep(ITester t)
        {
            t.Report.FailStep("REPLACE_OR_DELETE_ME");
        }

        [TearDownTest]
        public bool TearDown(ITester t)
        {
            return true;
        }
    }
}

ITester

The ITester interface allows you to access the functionality of the engine. There are several way in each you can use the interface. Please refer to the Object References chapter for full details regarding the available options.

[TestCase(number)] tag

This tag "tells" the engine that the class is a test case. The number part represents the revision number of the test case.

Example 1: Test Case Revision 1 is represented as [TestCase(1)]

Example 2: Test Case Revision 7 is represented as [TestCase(7)]

Do not delete the Test Case tag from the class. Otherwise the engine will not be able to recognize the class as Test Case.

[SetupTest] tag

Within this tag the test case instantiates the test model. The underlying method needs to return true in order for the test case to work. If the method returns false the test case will abort.

 [SetupTest]
        public bool Setup(ITester t)
        {
            App = new ExampleApp(t); //test model instantiation 
            return true; // method needs to return true
        }

[PreconditionStep] tag

Within the method defined with this tag you specify the actions necessary to fulfill the preconditions. The action function needs to return true in order for the PreconditionStep to pass. You can report that the step passes or fails as follows:

        [PreconditionStep]
        public void PreconditionStep(ITester t)
        {
            // Actions to fulfill the Preconditions
            t.Testee.Mouse.Click(text: "Run");
            
            if(t.Testee.FindImage(Images.Software.RunningState).HasSucceeded)
            {
                //PassStep will return true
                t.Report.PassStep("Software is in runing state");
            }
            else
                //FailStep will return false
                t.Report.FailStep("Software is not in running state");            
        }

[TestStep] tag

Within the method defined with this tag you specify the test step actions. The tag has additional attributes which define the steps number, test input and expected results.

[TestStep(1,
            TestInput = "Click on the LogIn button",
            ExpectedResults = "Login is not successfull as the user creneditals are not enetered")]
        public void Step1(ITester t)
        {
            t.Testee.Mouse.Click(Images.Software.LogIn);

            if(t.Testee.FindImage(Images.Software.LoginPage)
                t.Report.PassStep("LogIn button is not successfull as the user creneditals are not enetered");
            else
                t.Report.FailStep("Login was successfull");
        }

Tag attributes:

Attribute

Type

Description

Mandatory

Example usage

sequence

int

Defines the step number

Yes

[TestStep(1)]

TestInput

string

Defines the test input

Yes

[TestStep(1,

TestInput = "Click on the LogIn button")]

ExpectedResult

string

Defined the steps Expected Results

No

[TestStep(1,

TestInput = "Click on the LogIn button",

ExpectedResults = "Login is not successfull")]

[CleanupStep] tag

Within the method defined with this tag you specify the actions necessary to fulfill the cleanup step. The action function needs to return true in order for the CleanupStep to pass. You can report that the step passes or fails as follows:

        [CleanupStep]
        public void CleanupStep(ITester t)
        {
            // Actions to fulfill the CleanUp
            t.Testee.Mouse.Click(text: "Stop App");
            
            if(t.Testee.FindImage(Images.Software.StopState).HasSucceeded)
            {
                //PassStep will return true
                t.Report.PassStep("Software is stopped");
            }
            else
                //FailStep will return false
                t.Report.FailStep("Software is not stopped");            
        }

[TearDownTest] tag

Within this tag the your tear down your test. The underlying method needs to return true in order for the test case to work. If the method returns false the test case will fail.

 [TearDownTest]
        public bool TearDown(ITester t)
        {
           return true; // method needs to return true
        }

Last updated