Few question:Test as step log & building big test with authentication & copying steps to another WebAiiTest

6 posts, 0 answers
  1. Jari Jämsä
    Jari Jämsä avatar
    10 posts
    Member since:
    Apr 2010

    Posted 04 May 2010 Link to this post

    Hi again,

    i will made my first big automated test and i found few things more what i want to ask.

    1. When i have embed test inside another test (Test as step). In embed child test there is one to -n text verification`s (wait for 'text contents'...) or another content verifications. When some of child test text verification fails, i only see in test result, log text "content does not match". So i don`t know which text verification causes fail. I also tried to write custom message to LogMessageOnFailure -properties but it is also unvisible. Is there any solution for that?

    2. second question is how do you success to build tests with authentication? Now my solution is next (otherwice is fine exept proplem above):
    * I have main test where is log in system and main test also including data driving table for user:password and other user information. 
    * In main test i have child test`s (embed with Test as step) where i test different separated areas.

    Other options to do this is:
    * Write only one (very) big test or
    * Write own test for every separated areas (with authentication)

    => For my point of view one main test where is child test (embedded wit Step as step) is best solution. Second option where is only one big test is very messy and hard to read (because of amount od steps and there is no any grouping functionality).
    Third option is otherwice ok run each separated areas as own test`s but then i have to authenticate every time again (it`s annoing and it`s slower test a lot).

    3. I have several test where steps are similar. Is that possible copy somehow steps between webaii -tests? If not maybe this is coming in later version?

    Best regards, Jari Jämsä
  2. Missing user
    Missing user avatar

    Posted 04 May 2010 Link to this post

    Hello Jari,

    Thanks for the post and questions, I'll address your questions by point if that's alright.

    1) I was able to reproduce this and you are right, unfortunately there is not alot of description on which exact step that fails in a Test as a Step.

    From your previous tickets and this ticket description, it looks like you are using WebUI Dev Edition. If this is the case, please add this to the outer test in a code behind file:

    public override void CleanUp()
          {
              //
              // Place any additional cleanup here
              //
              if (this.ExecutionContext.TestResult.FailureException != null)
                  Log.WriteLine("Failed Step: " + this.ExecutionContext.CurrentStep.Description);
              #region WebAii CleanUp
              // Shuts down WebAii manager and closes all browsers currently running
              // after each test. This call is ignored if recycleBrowser is set
              base.CleanUp();
              #endregion
          }

    The above should override the test cleanup class and write out the failing step description to the test log. Please post back if you have any further questions on this.

    2) From a test maintenance percpective, if you can use smaller tests with authentication, that way you can more easily change and update a test for a particular scenario.

    3) Again, unfortunately copy steps across tests in Dev Edition is not supported, but you can actually does this QA Edition.

    I'll log a bug for both 1 and 4, thanks for all your feedback.

    All the best,
    Nelson
    the Telerik team

    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
  3. Jari Jämsä
    Jari Jämsä avatar
    10 posts
    Member since:
    Apr 2010

    Posted 05 May 2010 Link to this post

    Hello Nelson,

    Yes, i`m using developemend edition.

    i tried your code solution (CleanUp override). It wasn`t work directly, first it needs:  ArtOfTest.Common.Design and System.Runtime.Serialization.dll references. And some modifivation to code. And i`m not sure do i use this code now like you mean to use it.

    Now i will use it next way:
    1. I will create next method:

      [CodedStep("Manually fix log write")] 
            public void FixLog() 
            { 
                CleanUp(); 
            } 

    2. Then i notice at your FailureException is allways null in my case, so i change it like below.

     public override void CleanUp() 
            { 
                // 
                // Place any additional cleanup here 
                // 
             
                if (this.ExecutionContext.TestResult.FailureException == null) 
                { 
                    Log.WriteLine("Failed Step: " + this.ExecutionContext.CurrentStep.Description); 
                } 
     
                #region WebAii CleanUp 
                 
                // Shuts down WebAii manager and closes all browsers currently running 
                // after each test. This call is ignored if recycleBrowser is set 
                base.CleanUp(); 
                 
                #endregion 
            } 

    3. I change to step for text verification to Continue if failure  (otherways FixLog is not aver run).
    4. Then i will run my FixLog() method last in my test (after failures). (But basicly this should be after each step which can be cause failure because it only shows last failure...)

    Now i can see log when i run test by visual studio (In test result) but if i run test by quick execute button (webUI test studio own test execute) i still see only "content does not match" text.


  4. Missing user
    Missing user avatar

    Posted 05 May 2010 Link to this post

    Hi again Jari,

    Sorry if my last post caused any confusion. So you would not need to create a customized step to call CleanUp(), you would just need to have the code I posted in the outer test's code behind file. 

    So the outer test code behind should look something like this:

    using System;
    using System.Text;
    using System.Collections.Generic;
      
    using ArtOfTest.WebAii.Core;
    using ArtOfTest.WebAii.ObjectModel;
    using ArtOfTest.WebAii.Controls.HtmlControls;
    using ArtOfTest.WebAii.Controls.HtmlControls.HtmlAsserts;
    using ArtOfTest.WebAii.Silverlight;
    using ArtOfTest.WebAii.Silverlight.UI;
    using ArtOfTest.WebAii.Design.Execution;
    using ArtOfTest.WebAii.Design;
    using Telerik.WebAii.Controls.Html;
    using Telerik.WebAii.Controls.Xaml;
      
    namespace TestProject22
    {
      
        //
        // You can add custom execution steps by simply
        // adding a void function and decorating it with the [CodedStep] 
        // attribute to the test method. 
        // Those steps will automatically show up in the test steps on save.
        //
        // The BaseWebAiiTest exposes all key objects that you can use
        // to access the current testcase context. [i.e. ActiveBrowser, Find ..etc]
        //
        // Data driven tests can use the Data[columnIndex] or Data["columnName"] 
        // to access data for a specific data iteration.
        //
        // Example:
        //
        // [CodedStep("MyCustom Step Description")]
        // public void MyCustomStep()
        // {
        //      // Custom code goes here
        //      ActiveBrowser.NavigateTo("http://www.google.com");
        //
        //      // Or
        //      ActiveBrowser.NavigateTo(Data["url"]);
        // }
        //
              
      
        public class ExampleTest : BaseWebAiiTest
        {
            #region [ Dynamic Pages Reference ]
      
            private Pages _pages;
      
            /// <summary>
            /// Gets the Pages object that has references
            /// to all the elements, frames or regions
            /// in this project.
            /// </summary>
            public Pages Pages
            {
                get
                {
                    if (_pages == null)
                    {
                        _pages = new Pages(Manager.Current);
                    }
                    return _pages;
                }
            }
      
            public override void CleanUp()
            {
                // 
                // Place any additional cleanup here 
                // 
                if (this.ExecutionContext.TestResult.FailureException != null)
                    Log.WriteLine("Failed Step: " + this.ExecutionContext.CurrentStep.Description);
                #region WebAii CleanUp
                // Shuts down WebAii manager and closes all browsers currently running 
                // after each test. This call is ignored if recycleBrowser is set 
                base.CleanUp();
                #endregion
            }
      
            #endregion
              
            // Add your test methods here...
        }
    }

    And the line should be if (this.ExecutionContext.TestResult.FailureException != null)

    because the Test as a Step failure should propagate here and the if block be evaluated to true, then write the step description to the log.

    Your right in that in your implementation and the one I mentioned above will only write the most current step failure to the log. I'll log a feature request for also writing any step marked continue on failure's failure information to the log.

    Please try doing an explicit clean/build of the solution before running in Quick Exe mode, and the log should be at least displayed when you click on the button in the attached screenshot.

    Best wishes,
    Nelson Sin
    the Telerik team

    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
  5. Jari Jämsä
    Jari Jämsä avatar
    10 posts
    Member since:
    Apr 2010

    Posted 06 May 2010 Link to this post

    Hello again,

    and thanks for specific information.

    I understood wrong term 'outer test'. So 'outer test' mean main test, not embedded (step as a step) test.

    After i add CleanUp() method to my main test it works now better.

    I found new minor 'bug / feature' (see attachment). When you run your test by quick execute and open test result by red ellipse below (where failure step is), log is not show this empedded test failure text. But if you open test from bottom (View test log) you see embedded test failure text.

    Best regards, Jari Jämsä

  6. Missing user
    Missing user avatar

    Posted 06 May 2010 Link to this post

    Hello again Jari,

    I'm glad you got this partially working and thanks for the screenshot. The workaround I sent may not work in all cases as I believe that Failure Resolution UI is new in the latest version.

    I logged a bug for this, please bare with us as we'll look to have a more permanent solution in the works soon.

    Best wishes,
    Nelson
    the Telerik team

    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
Back to Top