Download Ajax and REST Recipes: A Problem-Solution Approach by Christian Gross PDF

Trace output

The code is relatively long, so I’ve highlighted the important pieces to make it simpler to understand.

The tests have to serve a dual purpose—that is, they have to provide tests as well as act as documentation for how the contracts are called and used. Therefore, it’s important that you structure the tests clearly and make them verbose. For programming purposes, you can code the test framework in any particular language that makes you comfortable. For the scope of this solution and this book, I use JavaScript and JsUnit to write my test scripts. NET language, PHP, or Ruby. You can start the contract in one of two ways: You can implement the client side first, or you can implement the Mock URL layer first.

When you implement the client-side tests of your contract, you’ll want to employ test-driven development techniques that include tests that succeed and tests that fail. Now let’s shift focus from the client side to the server side. You don’t want to implement a complete working server-side implementation, but rather implement the Mock URL layer. For the scope of this solution, Java is used. The purpose of the Mock URL layer is to imitate and implement server-side functionality. Imitating and implementing server-side functionality is tricky, because you can only implement targeted test cases.

Download PDF sample

Rated 4.31 of 5 – based on 41 votes