locked
How to change an assertion value variable

    Pregunta

  • How can I change the "recorded" value in an assert to be variable?  In the example below I want to make the uIAdmin_Hyperlink.FriendlyName variable.  It was originally recorded as "admin" but I want to make it variable depending on the test/user I am running.

    // Verify that 'admin' link's property 'FriendlyName' equals 'admin'

    Assert.AreEqual(this.VerifyAcctNameExpectedValues.UIAdmin_HyperlinkFriendlyName, uIAdmin_Hyperlink.FriendlyName);

    I know how to change the "expected" value by doing the following before the actual call:

    ///Type 'Stester' in 'txtUserName' text box

    this.UIMap.BasicHappyPathLoginWebParams.UIScreenNameEditText = "stester";

    martes, 13 de marzo de 2012 15:32

Respuestas

  • Hi,

    The recroded value for assertion gets stored by this.VerifyAcctNameExpectedValues.UIAdmin_HyperlinkFriendlyName. So you will have to parameterize this property:

    // The value is 'Admin'
    Assert.AreEqual(this.VerifyAcctNameExpectedValues.UIAdmin_HyperlinkFriendlyName, uIAdmin_Hyperlink.FriendlyName);
    
    this.VerifyAcctNameExpectedValues.UIAdmin_HyperlinkFriendlyName = 'Logout'
    // The value is 'Logout'
    Assert.AreEqual(this.VerifyAcctNameExpectedValues.UIAdmin_HyperlinkFriendlyName, uIAdmin_Hyperlink.FriendlyName);
    
    this.VerifyAcctNameExpectedValues.UIAdmin_HyperlinkFriendlyName = 'Help'
    // The value is 'Help'
    Assert.AreEqual(this.VerifyAcctNameExpectedValues.UIAdmin_HyperlinkFriendlyName, uIAdmin_Hyperlink.FriendlyName);

    See How to: Create a Data-Driven Coded UI Test.

    -Tejas.

    martes, 13 de marzo de 2012 16:32