How to unit test business rule methods
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-23-2019 11:51 PM
Dear all,
I am studding the best practice for implementation unit testing in Service-now.
For that I have cover different documentation on ATF and Jasmine framework.
To day I understand we have 2 different point to consider:
- Testing for Client operation in service by action like open a catalog and create a record.....Depending of the type of test some action occurs from client side or and server side from the ATF.
- Second point to consider are the unit testing of custom script include where we have potentially implement as custom use and for that we need to user Server script with jasmine implementation.
Now my question is at 2 levels :
Q1:
Normally when we talk about Unit testing, we should never gets data from database directly but instead using Mock-up data to unit test methods. Can this be apply in Service-now, if yes how those mock-up can be define ?
Q2:
IF we have some methods in certain business rules, how can we unit test those method inside business rule ?
Thanks for sample
- Labels:
-
Automated Test Framework
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-24-2019 12:32 AM
Hi
Below link will help you understand the process
https://community.servicenow.com/community?id=community_blog&sys_id=1a4e66addbd0dbc01dcaf3231f96192f
Note: Please mark reply as CORRECT if it has answered your question OR mark it as HELPFUL if it has guided you towards the solution
Thanks
Chandu
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-27-2019 07:50 AM
The data from the database that is created, modified or deleted gets rolled back after each test, that's why it's not an issue to use live data directly, though ATF tests are meant to run on sub-production environments only.
What you can do is run steps whose only purpose is to create mock-up data in preparation for your actual tests. Tests can't share data between themselves, so you'd have to add those data-creating steps on each individual test. You can use test templates for those repetitive steps to save time.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-28-2019 01:38 AM
I think you miss undertsand.
What I am trying to unit test is the cusom script includes methods that I have build for an qpplication.
So it is Server script step test using Jasmine syntax
In jasmine code script I define all my "desscribe" and "it" section which identify my test
Then I have a beforeEcah jasmine keyword which initialise my script include insstance to be used in my jasmine test.
Then from that instance object I cal call each method I need to test
Before calling some of those methods, I need to initialise some mock up data
If I create some records from that jasmine script as mockup, will they be also rollback at the end of the process for this all Server side test ?
regarsd