Follow

Recruiter 2.0 End to End Testing Guide (snaptest)

This article is designed to provide a step-by-step guide for setting up End-to-end testing on angular projects.

 

I. How it works (simple unit test creation and verification):

0. Add SnapTest extension to your Chrome  https://chrome.google.com/webstore/search/snaptest%20io

1. Click over SnapTest icon  in Chrome toolbar.

2. Click on “Test in this tab” 

    

3. Login with credentials: dkondratyev@samaritan.com Password: hjvfytyrj

4. Open https://sh.samaritan.com/signin/#!/login

5. Click “Set active tab” 

    

6. Click add new test

    

7. Click on newly added “Unnamed test”, click on edit button nearly “Unnamed test” and change name to "Hello Test"

    

8. Press Record and perform all the actions that you want to appear in the test case.

    

9. Go back to Chrome tab 

10. Click the gear on the left top corner

    

Type “ppp” in username and “ppp” in password fields, press “Sign In”.  

11. All steps are stored now. Let's setup successful completion verification.

Go back to SnapTest window and click the assert button.

     

Then Go back to Chrome tab and click on element that should be available for checking that log in unit test working correctly (for example “Save” button, or gear icon)

    

 

Go back to SnapTest tool and check that assert has added (should be “El is present...”)

 

12. Test verification

  • Clear browser cache and open https://sh.samaritan.com/signin/#!/login
  • Open SnapTest tool and open newly created test
  • Press play, then reload project tab
  • Check that all your stored actions are repeated in project tab
  • Check that all actions were passed and highlighted in green 

13. Publish new test. In SnapTest window drag and drop new test to the tests group.

    

14. Save everything in snaptest cloud (git)

      

15. How to see testing results.

After each change (push) in the git CStools repository, Jenkins on SH server deploys cstools build to cstoolsdev.samaritan.com instance on rs15 and run tests over few instances:

  • 8203 - sh.samaritan.com/signin
  • 8202 - drexelqa.samaritan.com
  • 8201 - atlantamissionqa.samaritan.com

After testing completed it sends email with results to Damien, Dima, Egor and Pavel.

Detailed report available by direct link: http://jenkins.samaritan.com:8080/view/Deploy%20Production/job/RS15%20deploy%20and%20test%20CStoolsDev/Snaptest_Report/

In case build is UNSTABLE, then developer who applied last changes should review last commits and fix problem caused tests fail ASAP.

 

II. Advanced/complex unit test creation: 

A) Lead-up

 Please note:

  • Do not add SnapTest asserts to small actions and actions, asserts should be used only for tests
  • Please check that components and tests have only global variable
  • Do not use values that should be global variables (left – not good, right - good)
  • Please make “load page” SnapTest action as separate component and remove it all the time when it appears when you create new component or test (left – bad, right - good)
  • Please remove all variables that will be automatically added to component and tests
  • Remember that all tests executed parallel, so it will be perfect if each test will start with
    1. Clear cache
    2. Open project
    3. Login
    4. Make some settings
    5. Unit test

 

B) Create test for volunteer sign in

  • Open https://sh.samaritan.com/signin/#!/login
  • Click “Set active tab”
  • First of all we should configure station
    1. We need 2 actions
      1. Admin login 
      2. Configure station 
    2. For actions we should have small actions, that will be used multiple times in the future
      1. Open sign in 
      2. Go to Admin login page 
      3. Fill admin form 
      4. Go to settings 
      5. Change station 
      6. Change opp 
      7. Save settings 
  • Then we should configure station through browser and press save 
  • add new test
    • Rename test to “Volunteer sign in”
    • Test should be started from clearing cache
    • Then we should add “Open sign in” small action
    • Then we should add “Admin login vc” action
    • Then we should add “Configure station” action 
  • Now we have configured station and we ready to add new action “Volunteer login vc”
    • Add component “Volunteer login vc”
    • Move it to actions folder 
    • Open component to edit
    • Check that action have no variables
    • Press record
    • Remove “Load page” snaptest action
    • Click on Username and enter some value
    • Click on password and enter some value
    • Check that actions were recorded 
    • Remove snaptest click actions and change input values to global variables 
    • Press record and click “Continue” button, now we have new action that can be used multiple times 
    • Add this action to test 
    • Now our test looks like some action and have no asserts, lets add asserts and check that volunteer was signed in 
  • Now test is ready, don’t forget add newly global variables to nightwatch.json config file

 

 

III. Local machine installation and execution

A. Installation

  • Download and install latest nodejs - https://nodejs.org/en/
  • Download and install Java (minimum required version is 7) - http://www.oracle.com/technetwork/java/javase/downloads/index.html
  • Download chrome driver https://sites.google.com/a/chromium.org/chromedriver/downloads
  • Install nightwatchjs via type in cmd console (if you don't know how, please see attached CMD.docx) following command "npm install -g nightwatch"
  • Install handlebars via type in cmd following command "npm install -g handlebars"
  • Add “C:\Users\[USER]\AppData\Roaming\npm;C:\Program Files\nodejs\;” to path variable, where [USER] your current user in windows system (see details in attached Edit path variable.docx)
  • Add SnapTest extension to your Chrome  https://chrome.google.com/webstore/search/snaptest%20io
  • Install snaptest-cli via cmd command "npm install -g snaptest-cli"
  • Open disk C: and create "unit" folder and extract all files from snaptest-harness.zip

B. Configure 

  • Please open nightwatch.json file in notepad++ (you should change only instances settings) 
  • For example “default” instance
  • Launch_url – instance that should be tested, don’t forget to add ?unit at the end.
  • Output_folder – folder where will be test results, please write it like “reports/[instance name]”
  • Globals – globals variables
  • "filter" change to  "snaptests/tests/*/*.js"
  • You can add new instance if you want, just copy default settings and paste them after “default” instance, don’t forget to change name of instance 
  • You can change which instance should be tested
  • Open start.cmd in notepad++ and change find next string 
  • Change this string to nightwatch –e [instance name]
  • You can load parallel testing of multiple instances 
  • Open start.cmd in notepad++ and change find next string 
  • Change this string to nightwatch –e [instance name], [other instance name] e.g. nightwatch –e default,sh

  

C. Execution

  • Click on start.cmd file and wait for results
  • To view results open C:\unit\snaptest-harness\reports\fullReport.html 
  • Where [instance] – [Test name] in first column
  • You can click on each test and check performed actions

 D. Verify newly created test if need

  • Please move test in the “na tests” folder ("na" means "not added")
  • Click on checkNaTests.cmd file and wait for results
  • Open C:\unit\snaptest-harness\reports\fullReport.html and check results of your test
  • If everything is ok, you should move your test to tests folder and it will be added automatically to all unit tests
  • Click on start.cmd file and wait for results
  • Open C:\unit\snaptest-harness\reports\fullReport.html and check that your test appears in results
  • Move created test to “tests” folder AFTER check

 

 

III. Naming Conventions and Test Organization: 

  1. Tests should be written to provide reasonable coverage of Development tickets which present bugs or new functionality.
  2. Each test case that covers a specific development ticket should be indicated in the description of that test case.
  3. Test cases should be structured to cover a specific area or functional feature of the system.  eg: "Refer/Place volunteer".
  4. When possible, to improve performance, multiple test cases should be included under the same automated test.  eg: "Refer/place volunteer" can cover referral, placement, unplacement, placement to a schedule slot, group placement to a schedule slot, inability to place due to prerequisites etc...
  5. Each test that is used to cover a particular Jira ticket should be listed  in the Jira ticket's "Steps to Reproduce" field as the name of the test (see screenshots).

test-case-documentation.PNG         test-case-documentation2.PNG

 

 

Was this article helpful?
0 out of 0 found this helpful
Have more questions? Submit a request

Comments

Powered by Zendesk