Executing from the command line

With the 1.1.9 release the ability to execute tests from the command line is now possible.  This can be achieved by creating an ironpython script that will execute the tests. Shown below is the usage

USAGE : WcfStormConsole.exe <Script file> <Url> [Other urls]
        WcfStormConsole.exe <Script file> <*.wcfstormproject.xml file>

---------
Required:
---------

The 1st argument is always the script file. The 2nd argument can either be a service URL or a WcfStorm project file.

[Other URLs] 
             : These are the urls that will be accessed from the script and is different from the initial <Url> parameter
             : This can only be used if the 2nd argument is a URL and not a WcfStormProject file.

As can be seen from the usage a bove, there are 2 ways that the command line can be used.  It can be used to test a project that has been created using GUI; with which you'll have access to all the test cases belonging to the project.  It can also be used to test more than one endpoint.  With this option you can invoke wcf methods and manually do the validation of the responses.

Testing a wcfstorm project from the command line

  1. Create a project containing test cases
  2. Create the IronPython test script

    For example, assuming we have 2 test cases "MyFunctionalTest" and "MyFunctionalTest2" for the service with URL http://localhost:8081/TestWS/Service.asmx  (as shown below)



    Suppose we want to execute the "MyFunctionalTest" using a script, we'd have something like

    -----------------------------------------------------------------------------------------

    #Run the test case and validate that the actual response matched the expected response.
    valResult = task.RunFunctionalTestCaseAndValidate("http://localhost:8081/TestWS/Service.asmx", "ServiceSoap", "TestNullableType", "MyFunctionalTest" )
    if valResult.IsPass:
      print "Expected and actual response matched!"
    else:
      print "Validation failed! Displaying result"
      #show the responses side-by-side
      task.DisplayTestValidation(valResult)

    -----------------------------------------------------------------------------------------

    The method RunFunctionalTestCaseAndValidate of the task variable has the following signature
    public ScrTestCaseValidationResult RunFunctionalTestCaseAndValidate(string url, string contractName, string method, string testcaseName)
    it takes the URL, contract name, method name and the test case name.  The return type ScrTestValidationResult has the following properties

    public class ScrTestCaseValidationResult
    {
    public string ErrorsAsHtml { get; private set; }
    public string ActualResponse { get; private set; }
    public string ExpectedResponse { get; private set; }
    public bool IsPass { get; private set; }
    }


    ErrorsAsHtml : this is an html that displays the actual and expected response side-by-side
    ActualResponse: the response in XML format
    ExpectedResponse: the expected response in XML format
    IsPass : Boolean flag to indicate whether the validation passed.  Note that this flag will take into account any custom validations from plugins (if any)
     
  3. Save the script to a file
  4. Close WCFStorm GUI.
  5. Open the command prompt and execute

    WcfstormConsole.exe {pathToScriptFile}\MyTest.py {PathToProject}\MyTestProject.wcfstormproject.xml

 

 

 

 

 


Site Map | Printable View | © 2008 - 2024 WCFStorm Solutions

Powered by mojoPortal | XHTML 1.0 | CSS | Design by styleshout