PERHAPS A GIFT VOUCHER FOR MUM?: MOTHER'S DAY

Close Notification

Your cart does not contain any items

Build Your Own Test Framework

A Practical Guide to Writing Better Automated Tests

Daniel Irvine

$88.95   $75.33

Paperback

Not in-store but you can order this
How long will it take?

QTY:

English
APress
10 March 2023
"Learn to write better automated tests that will dramatically increase your productivity and have fun while doing so. This book is a build-your-own adventure designed for individual reading and for collaborative workshops.  You will build an xUnit automated test framework using JavaScript: initially a clone of Jest, but adding a couple of neat features borrowed from RSpec, the genre-defining tool for behavior-driven development (BDD). Along the way, you will explore the philosophy behind automated testing best practices. The automated test runner is one of the most important innovations within software engineering. But for many programmers, automated testing remains a mystery, and knowing how to write good tests is akin to sorcery. As the chapters of this book unfold, you will see how the humble test runner is an elegant and simple piece of software. Each chapter picks a single feature to build, like the ""it"" function or the ""beforeEach"" block. It picks apart the theory of why the feature needs to exist, and how to use it effectively in your own test suites. Every chapter ends with a set of ideas for extension points should you wish to explore further, alone or in groups. The book culminates in an implementation of test doubles and mocks—one of the most difficult and misunderstood concepts within automated testing. By the end of the book, you will have gained a solid understanding of automated testing principles that you can immediately apply to your work projects.  What You'll Learn

Build an xUnit automated test framework See how an automated test runner works Understand the best practices for automated unit testing Effectively use test doubles and mocks

Who This Book Is For

Software developers with JavaScript experience who are seeking to master the art of automated testing. "

By:  
Imprint:   APress
Country of Publication:   United States
Edition:   1st ed.
Dimensions:   Height: 235mm,  Width: 155mm, 
Weight:   456g
ISBN:   9781484292464
ISBN 10:   1484292464
Pages:   269
Publication Date:  
Audience:   Professional and scholarly ,  Undergraduate
Format:   Paperback
Publisher's Status:   Active
Part 1: Building the Core of a Test Framework In this part we build a barebones implementation of a test runner.Chapter 1: Creating an NPM Package of My Very Own, You will create a new NPM package for concise-test, including an entry-point for the test runner. Chapter 2: Building it to Define a Testwe’ll implement the it function for defining tests, and start printing out some useful test run information on screen. Chapter 3: Grouping Tests with Describe, we’ll add support for grouping tests with the describe function, and we’ll continue to build out test reporting on screen.  Chapter 4: Promoting Conciseness with BeforeEach and AfterEachWe continue our quest for concise testing facilities with the addition of beforeEach and afterEach functions.  Chapter 5: Improving Legibility with Expect, We finish off the core of our API by building an abstraction over throw new Error.  Part 2: Constructing a Usable Framework In this part we add features that you’ll use on a daily basis.  Chapter 6: Formatting Expectation ErrorsWe write a formatter for stack traces to help pinpoint failures quickly.  Chapter 7. Automatically Discovering Test FilesWe’ll add test file discovery to our test runner, and add support for running a single file through a command line argument.  Chapter 8: Focusing on Tests with It.Only and Describe.Only, We split out runner into two phases: a discovery phase and an execution phase. In between them, we insert a filter phase to support running only a subset of phases.  Chapter 9: Supporting Asynchronous Tests, We add the ability to wait on tests that return Promise objects, and timing out tests with it.timesOutAfter.  Chapter 10: Reportingwe use a pub-sub model to build a plug-in system for reporters.  Part 3: Extending for Power Users In this part we continue to add advanced features.  Chapter 11: Sharing Behavior with it.BehavesLike, We borrow an important feature from Ruby: inheritance for describe blocks, which gives us a flexible mechanism for removing duplication between test groups.  Chapter 12: Tagging Tests We create a mechanism for running a group of tests based on their tag.  Chapter 13 : Skipping Tests we introduce a number of ways to skip tests, including tests without bodies, and it.skip plus describe.skip functions.  Chapter 14 : Randomizing TestsWe add a runtime flag for randomizing the order of tests, which is a useful technique for catching invisible dependencies between tests.  Part 4: Test Doubles and MocksChapter 15. Understanding test doubleswe create a function that can be used as a test spy and stub. Chapter 16. Module MocksWe create a system for mocking out entire modules, which is a useful technique when creating component doubles when testing React.

Daniel Irvine is a freelance software developer based in London. He works with a variety of languages including C#, Clojure, JavaScript, and Ruby. When he’s not working, he spends time cooking, gardening and practicing yoga. He co-founded the Queer Code London meetup and is an active member of the European software craft community.

See Also