What’s in a Method?

Here is a style question.

For a test I am working on, I have a simple table that lists a User Role. That role is a clickable link. I have two things I want to check on this page.

First, I want to check that the User Role is a known text value, such as Admin or Sales Rep.

Second, I want to check that the link for that role is Clickable.

This is a simple validation test of two pieces of information. But, the question is, should both of these items be checked within one method, or should it be done as two?

This is a simple example, where the isClickable is determined right after the searchResult. It's something I am literally working on right now. Is it more advantageous and proper to have the method check a single point of failure, or should it work on related items at the same time without making another call?

Example 1:
//Verify search results
def confirmSearch(String searchText, int row){
    KeywordLogger log = new KeywordLogger()
    String searchResult=WebUI.getText(findTestObject('Roles/table-Roles', [('row') : row, ('column') : 1]))
    log.logWarning(searchText + " : " + searchResult)
    if (searchResult.contains(searchText)!=true){
        KeywordUtil.markFailed('ERROR: The User Role is not displayed correctly in the Role Management table')
    }
}

//Verify User Roles links are clickable
def confirmLink(String userRole, int row){
    boolean isClickable
    isClickable=WebUI.verifyElementClickable(findTestObject('Roles/table-Roles', [('row') : row, ('column') : 1]))
    if (isClickable!=true){
        KeywordUtil.markFailed('ERROR: The User Role ' + userRole + ' was not clickable')
    }
}

Example 2:

//Verify search results
def confirmSearch(String searchText, int row){
    boolean isClickable
    KeywordLogger log = new KeywordLogger()
    String searchResult=WebUI.getText(findTestObject('Roles/table-Roles', [('row') : row, ('column') : 1]))
    log.logWarning(searchText + " : " + searchResult)
    if (searchResult.contains(searchText)!=true){
        KeywordUtil.markFailed('ERROR: The User Role is not displayed correctly in the Role Management table')
    }
    isClickable=WebUI.verifyElementClickable(findTestObject('Roles/table-Roles', [('row') : row, ('column') : 1]))
    if (isClickable!=true){
        KeywordUtil.markFailed('ERROR: The User Role ' + userRole + ' was not clickable')
    }
}
Made with 100% recycled electrons.

Author Signature for Posts

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.