Skip to Content
Rails 5 Test Prescriptions
book

Rails 5 Test Prescriptions

by Noel Rappin
February 2018
Intermediate to advanced
406 pages
9h 52m
English
Pragmatic Bookshelf
Content preview from Rails 5 Test Prescriptions

Testing for Failure

Failure, of course, is always an option, so you need to test for it. I prefer to do failure-path testing in unit tests rather than end-to-end tests. Success requires the entire system to work in concert. A failure response can usually be isolated to one component. That said, it’s often useful to have one end-to-end failure test, especially in cases where the failure is easily causable and visible to a typical user.

I haven’t yet talked about the tools that will allow you to fake failure—that requires a mock object package. (See Chapter 7, Using Test Doubles as Mocks and Stubs.) But in this case it’s not hard to create a real failure by adding a validation that you can then not fulfill.

Let’s first see what an end-to-end ...

Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

Rails 4 Test Prescriptions

Rails 4 Test Prescriptions

Noel Rappin
What Employees Want Most in Uncertain Times

What Employees Want Most in Uncertain Times

Kristine W. Powers, Jessica B.B. Diaz
Agile Web Development with Rails 5.1

Agile Web Development with Rails 5.1

Sam Ruby, David B. Copeland, Dave Thomas

Publisher Resources

ISBN: 9781680505566Errata Page