Acceptance Tests
Also called
End-to-end tests, feature tests
A test that only interacts with the program through the public API. For a web app, this could mean running a fake browser and simulate clicking buttons. For a script, this could mean invoking it from a shell and checking the file it modified. The purpose of acceptance testing is to check that a “user” will see the program behave correctly. Hence the name: will the user accept the program as meeting the required functionality?
def test_clicking_button_changes_page():
driver = webdriver.Firefox()
driver.get(“http://website.example.com”)
driver.find_element_by_id(“button”).click()
assert driver.title == “New Page”
Acceptance tests make up the top of the Testing Pyramid. They’re considered important but should be used sparingly. They are even slower than integration tests and can have serious nondeterminism issues. This is especially true with browser automation, as the browser still has to wait on server response, load all of the assets, run js, etc. And what happens if the server never responds? The test would hang unless you include a timeout, but then what if the server is responds, just slowly? And we haven’t even discussed the challenges of simulating the entire system, or dealing with third-party interactions. Once