Exploring Robot-ic QA Automation for Salesforce (Part 3)

Project Structure and example of create contact test case

Hello folks, We’re done setting up the Project structure and configuring the machine with all necessary plugins, extensions, and dependencies in parts 1 & 2. I strongly believe that you guys are a bit familiar with Robot Framework’s template of writing Test Scripts but if not, don’t worry, these following links will help:

Robot Framework Features Overview

Review the Robot Framework Template to write Test case in VS Code  (on this page, navigate to ‘Examples’ section and checkout Test cases, Keywords & Template Tabs).

Let’s understand the current Project structure. Your current project structure should be looking like this.

As an SDET, We’ve to work inside the auto-created robot/project_name folder & beneath the robot folder, Three more folders are created 1. Doc 2. Resources & 3. Tests

  • Doc : Inside this folder, we’ll maintain documents for test cases.

  • Resources : Inside this folder, we’ll place all Libraries, Resources which are global and later we can import it in tests.

  • Tests : This folder contains all your test files in .robot extension. you'll write your Test Cases here.

So, why wait? Let’s automate one Test Scenario. Upon creating Cumulus Project, By Default, you’ll get one Test case example using UI and API. 

  • First you need to install the CumulusCI library and place that inside the resource folder.

cmd : pip install cumulusci

After running this command navigate to the folder below in your machine C:\Users\YourMachineName\AppData\Local\Programs\Python\Python39\Lib\site-packages and copy the cumulusci folder and paste it inside your Project’s resources folder.

  • Now, navigate to the tests folder & open create_contact.robot file in Vs-code.

    • Inside the Settings feature, We can define Suite setup, Suite teardown, Resource, Library, Tags, Timeout & Documentation

      • Suite setup & teardown:  when it is assigned to test-case, setup will run before the test case and teardown will run after the test-case. In Current create_contact.robot file, Open Test Browser, Delete Records and Close Browser keywords are imported from the Salesforce.robot resource.

      • Resource : it helps in importing the keywords from other .robot files. You can import as many resources as you want by using the resource tag.

      • Library : it imports library keywords.

      • Tags : You can run your test case using tags and you need to provide those tags here.

      • Documentation : You can keep the test-case description here.

      • Inside the Test cases feature, You can define the Test cases & utilize the in-built and custom keywords to write your test cases. 

        • Format: (Robot Framework supports tabular formatting only.)

*** Test Cases ***

Test Case Name

Keyword variable(if any)

In the current create_contact.robot file we’ve created 2 Test cases i.e. 1. Via API, 2. Via UI. inside both the test cases, We’ve used faker & salesforce library to create contact.

  • Inside the Keyword feature, You can define your custom keywords and can use it in the Test case.

  • You can also define a variable feature inside the .robot file beneath the settings feature. These variables can be used directly in Keywords.

It’s time to run the Test cases written inside the create_contact file. To run the test cases use the below command inside your project folder:

cmd : cci task run robot -o suites robot/MyProject/tests/create_contact.robot --org qa

After running the above command, the results folder will be generated inside the robot/ProjectName. Copy the path of the report.html file and paste it into any browser to check the status of the Test cases. Robot Framework generates detailed reports and logs.

Now, give yourself a try to automate any of your salesforce projects. If you’re stuck somewhere and not able to find the solution, brief your problem in the comment section. We’re here to help ASAP.

To learn more about Exploring Robot-ic QA Automation for Salesforce. We have divided this blog into three parts click here to learn on 'Introduction to Framework & Prerequisites Installation' and 'Project Setup, Create/Manage QA orgs'.

We're always happy to answer any questions you might have. If you are interested in reading more articles on Salesforce. Check out some of our favorites here.

Thanks to our Salesforce Consultant Divy muni for this amazing blog post written with detailed information.

Reference Links:

  • https://cumulusci.readthedocs.io/en/stable/index.html#

  • https://partners.salesforce.com/pdx/s/learn/article/cumulusci-partner-fundamentals-MCXMA5YR4RGFHOTN6WOXZNVMDMZU?language=en_US

  • https://robotframework.org/

  • https://cumulusci.readthedocs.io/en/stable/robot.html#

  • https://developer.salesforce.com/docs/atlas.en-us.sfdx_setup.meta/sfdx_setup/sfdx_setup_install_cli.htm#sfdx_setup_install_cli_windows

Abhinav Gupta

First Indian Salesforce MVP, rewarded Eight times in a row, has been blogging about Salesforce, Cloud, AI, & Web3 since 2011. Founded 1st Salesforce Dreamin event in India, called “Jaipur Dev Fest”. A seasoned speaker at Dreamforce, Dreamin events, & local meets. Author of many popular GitHub repos featured in official Salesforce blogs, newsletters, and books.

https://abhinav.fyi
Previous
Previous

Exploring Robot-ic QA Automation for Salesforce (Part 2 )

Next
Next

Overview of Every B2C Salesforce Marketing Cloud Product