🐒MOCK

Overview

The MOCK class is a powerful component of our automated testing suite, designed to generate and manage mock data for a variety of testing scenarios. This class provides a range of functionalities to create realistic and random data, such as email addresses, names, phone numbers, and addresses, which are essential for robust and comprehensive testing.

Methods

  1. getConfigValue

    • Purpose: Retrieves specific configuration settings.

    • Usage: Useful for obtaining configurable parameters or settings that are crucial for the test environment. The method requires the name of the configuration file and the specific key to retrieve its value.

  2. generateRandomEmailAddress

    • Purpose: Creates a random email address.

    • Usage: Ideal for tests requiring unique email addresses. This method automatically generates a new email address each time it's called.

  3. getRandomEmail

    • Purpose: Retrieves the most recently generated email address.

    • Usage: Use this method to access the email address generated by generateRandomEmailAddress. It's helpful when you need to use the same email address in multiple test steps.

  4. getRandomEmailBody

    • Purpose: Extracts a specific part of an email body based on given parameters.

    • Usage: Essential for tests that require validation or verification of certain parts of an email content. Parameters guide the method to extract the relevant segment.

  5. GENERATE_DATE

    • Purpose: Produces a formatted date based on input parameters.

    • Usage: This method is useful when tests require date values. It allows for the generation of dates in various formats and offsets.

  6. FIRST_NAME

    • Purpose: Generates a random first name.

    • Usage: Ideal for tests needing a realistic first name. Each invocation produces a new name, enhancing test variability.

  7. LAST_NAME

    • Purpose: Generates a random last name.

    • Usage: Similar to FIRST_NAME, this method is used when a random last name is needed for testing purposes.

  8. PHONE_NUMBER

    • Purpose: Creates a random phone number.

    • Usage: Useful in scenarios where phone number validation or testing is required. It generates numbers in a realistic format.

  9. ADDRESS

    • Purpose: Generates a full random address.

    • Usage: When tests require an address input, this method provides a random, yet plausible, address, adding depth to testing scenarios.

Application in Testing

These methods can be invoked within automated test scripts to provide dynamic, realistic data inputs. For example, to test a sign-up form, you can use generateRandomEmailAddress to create a new email, FIRST_NAME and LAST_NAME for the user's name, and ADDRESS for the address fields.

How to Use

The MOCK class can be integrated into automated test scripts to generate and utilize dynamic data inputs. Below is a generic example template for using these methods in a typical web form automation script:

Example Script Template:

PAGE_NAME, WAIT_TYPE, SCROLL_TYPE, ELEMENT_NAME, ACTIONS, SEND_KEYS, VALIDATION, VALIDATION_TYPE
RegistrationForm, NONE, NONE, emailField, SEND_KEYS, MOCK:generateRandomEmailAddress, NONE, NONE

Conclusion

The MOCK class is an essential tool for creating dynamic and realistic test data. Its variety of methods caters to numerous testing scenarios, making it invaluable for ensuring comprehensive and effective automated testing.

Last updated

Was this helpful?