Unit testing Web applications

M

Monica Leko

Hi!

Does Python has some testing frameworks for testing Web applications
(like Cactus and HttpUnit for Java), generating requests and checking
if the response is correct?
 
D

Diez B. Roggisch

Monica said:
Hi!

Does Python has some testing frameworks for testing Web applications
(like Cactus and HttpUnit for Java), generating requests and checking
if the response is correct?

mechanize and webunit come to my mind.

Yet the most powerful will be selenium together with selenium-remote driven
via python. Don't forget to check out the brilliant selenium IDE.

Diez
 
R

Ryan Ginstrom

On Behalf Of Monica Leko
Does Python has some testing frameworks for testing Web
applications (like Cactus and HttpUnit for Java), generating
requests and checking if the response is correct?

I have got a lot of traction using mechanize [1] with nose [2]. Of course
that still leaves out testing JavaScript. For that, something like PAMIE [3]
is one way to go.

[1] http://wwwsearch.sourceforge.net/mechanize/
[2] http://somethingaboutorange.com/mrl/projects/nose/
[3] http://pamie.sourceforge.net/

Here's an example of how I use mechanize + nose:

# test_index.py
from mechanize import Browser

class TestPageLoads:

def setup(self):
self.mech = Browser()
self.mech.set_handle_robots(False) # use thought and
consideration...

def test_nonexistent(self):
try:
response =
self.mech.open("http://honyaku-archive.org/nonexistent/")
assert False, "Should have thrown here"
except Exception, e:
assert "404" in str(e), e

def test_index(self):
response = self.mech.open("http://honyaku-archive.org/")
assert response.code == 200, response.code

def test_index_title(self):
response = self.mech.open("http://honyaku-archive.org/")
assert self.mech.title().strip() == "Honyaku Archive :: Home",
self.mech.title()

Regards,
Ryan Ginstrom
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,012
Latest member
RoxanneDzm

Latest Threads

Top