- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-24-2018 08:48 AM
How can I write a test case in the Automated Test Framework to assert whether an e-mail notification has been sent? I have some ideas for how to script it, but has the community already settled on any best practices for this?
Solved! Go to Solution.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-30-2018 12:11 AM
Hi
I went to a ServiceNow Developer meetup last night where a senior technical consultant from ServiceNow did a deep dive into ATF. His advice was to use gs.sleep to put waits in to wait for any asynchronous updates, one of the example he gave was when checking if an email had been generated in sys_email table, so sounds like you're on the money 🙂
cheers
Bonnie

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-24-2018 10:09 AM
I would probably just query the sys_email table with filter type=sent and instance=((GlideRecord generating email))
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-24-2018 10:18 AM
Yeah, this is what I had kind of settled on, but this particular e-mail notification is event-based, so I think it takes it several milliseconds (maybe even several seconds) to propagate through the system (and in this case, I don't even care if it's `sent` or not, it can be `send-ready` and I'll consider that a pass). Is there a way to introduce a delay before a test step? Is that advisable? I don't want to have delays built into thousands of tests to the point where running our whole regression test suite takes multiple days. Haha.
EDIT: I introduced a 10-second delay (using gs.sleep(10000)). The test now passes. I still wonder if this is advisable though. Is there a better, more reliable way to do this?

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-30-2018 12:11 AM
Hi
I went to a ServiceNow Developer meetup last night where a senior technical consultant from ServiceNow did a deep dive into ATF. His advice was to use gs.sleep to put waits in to wait for any asynchronous updates, one of the example he gave was when checking if an email had been generated in sys_email table, so sounds like you're on the money 🙂
cheers
Bonnie
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-30-2018 08:48 AM
Thanks, Bonnie!