pysaunter for API testing?

26 views
Skip to first unread message

Mary Ann May-Pumphrey

unread,
Aug 1, 2013, 3:39:01 AM8/1/13
to sau...@googlegroups.com

Has anyone tried putting both their Selenium tests and their API tests under/into pysaunter? My co-worker's husband (who works at a place that does more and better automation than we do!) claims to be using the same (unnamed and probably in-house) framework for both types of tests. 

--mam-p

thirumal rao

unread,
Aug 1, 2013, 4:43:25 AM8/1/13
to sau...@googlegroups.com
At the top of my mind, Robot framework can be used... I am planning on using Robot for API testing unless someone here has a better suggestion...




On Thu, Aug 1, 2013 at 1:09 PM, Mary Ann May-Pumphrey <ma...@yahoo.com> wrote:

Has anyone tried putting both their Selenium tests and their API tests under/into pysaunter? My co-worker's husband (who works at a place that does more and better automation than we do!) claims to be using the same (unnamed and probably in-house) framework for both types of tests. 

--mam-p

--
You received this message because you are subscribed to the Google Groups "Saunter" group.
To unsubscribe from this group and stop receiving emails from it, send an email to saunter+u...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.
 
 



--
"Peace cannot be kept by force. It can only be achieved by understanding."

http://www.raoathisbest.blogspot.com

Wai (Dave) Tung

unread,
Aug 1, 2013, 4:49:12 AM8/1/13
to sau...@googlegroups.com, sau...@googlegroups.com
I have done this using Saunter before. I basically modified certain base classes to omit the creation of the browsers instance/driver. 

On 2013-08-01, at 3:39 AM, Mary Ann May-Pumphrey <ma...@yahoo.com> wrote:


Has anyone tried putting both their Selenium tests and their API tests under/into pysaunter? My co-worker's husband (who works at a place that does more and better automation than we do!) claims to be using the same (unnamed and probably in-house) framework for both types of tests. 

--mam-p

--

thirumal rao

unread,
Aug 1, 2013, 4:53:22 AM8/1/13
to sau...@googlegroups.com
Hi Dave, 

Great to know saunter can be used for API tests. Would you be able to share more details on what needs to be changed in Saunter.

Thanks
Thirumal 

Adam Goucher

unread,
Aug 1, 2013, 7:24:48 AM8/1/13
to sau...@googlegroups.com
IIRC, he just created two facade classes for SaunterTestCase; one which leaves setup_method() alone (gets you a browser) and one in which setup_method() establishes a connection to their webservice. Something like...

from tailored.browser_based import BrowserBasedScript

class CheckSomethingInABrowser(BrowserBasedScript):

vs

from tailored.browser_based import NotBrowserBasedScript

class CheckSomethingNotInABrowser(NotBrowserBasedScript)

Or at least that is how I would structure it.

-adam

Dakota Smith

unread,
Aug 1, 2013, 10:16:22 AM8/1/13
to sau...@googlegroups.com
Last place I worked we used PySaunter to run both our UI and our API/SDK tests. 

Since under the covers it is just py.test, it was rather straightforward to set up starting from exactly where Adam suggests. 

You'll need to also create some objects which you can use in your scripts. I recommend using the requests library for talking to the API. 

To see some examples, the browsermob-proxy-py library has some good examples of how to use requests library to send requests to your API. 

Dave Tung

unread,
Aug 2, 2013, 8:56:38 AM8/2/13
to sau...@googlegroups.com, sau...@googlegroups.com
Thirumal,

I did basically what Adam described. Unfortunately, I'm on a personal leave right now so I don't have my laptop handy but I'll describe what I can remember. 

To start I separated the scripts into /scripts/ui and /scripts/services. You'll notice in Adam's sample, each test script is a class that inherits from a SaunterTestCase. We have our own TestCase layer that inherits from SaunterTestCase. So for services testing you'll probably want a ServiceTestCase class some where, which inherits SaunterTestCase but override the setup_method. This is where the browsers driver is created I believe, you don't need or want this for your test. Its up to you if you want this class to inherit SaunterTestCase. I remember we did to use the soft asserts. If you don't care about that, you can use the native assertions. For each script, I'd create a service object, i.e. UserService, and do your thing. In each service object I made use of the request library but feel free to use urllib if you like. Doing it this way, it's easy to change later. 

That's pretty much it. Let me know if you have any questions. 
Reply all
Reply to author
Forward
0 new messages