Zum Hauptinhalt springen Zur Suche springen Zur Hauptnavigation springen

Build Your Own Test Framework

56,99 €

Sofort verfügbar, Lieferzeit: Sofort lieferbar

Format auswählen

Build Your Own Test Framework, Apress
A Practical Guide to Writing Better Automated Tests
Von Daniel Irvine, im heise Shop in digitaler Fassung erhältlich

Produktinformationen "Build Your Own Test Framework"

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.

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. 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 TEST

we’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 AFTEREACH

We 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 ERRORS

We write a formatter for stack traces to help pinpoint failures quickly.

CHAPTER 7. AUTOMATICALLY DISCOVERING TEST FILES

We’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: REPORTING

we 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 TESTS

We 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 MOCKS

Chapter 15. Understanding test doubles

we create a function that can be used as a test spy and stub.

CHAPTER 16. MODULE MOCKS

We create a system for mocking out entire modules, which is a useful technique when creating component doubles when testing React.

Artikel-Details

Anbieter:
Apress
Autor:
Daniel Irvine
Artikelnummer:
9781484292471
Veröffentlicht:
09.03.23

Barrierefreiheit

This PDF does not fully comply with PDF/UA standards, but does feature limited screen reader support, described non-text content (images, graphs), bookmarks for easy navigation and searchable, selecta

  • keine Vorlesefunktionen des Lesesystems deaktiviert (bis auf) (10)
  • navigierbares Inhaltsverzeichnis (11)
  • logische Lesereihenfolge eingehalten (13)
  • kurze Alternativtexte (z.B für Abbildungen) vorhanden (14)
  • Inhalt auch ohne Farbwahrnehmung verständlich dargestellt (25)
  • hoher Kontrast zwischen Text und Hintergrund (26)
  • Navigation über vor-/zurück-Elemente (29)
  • alle zum Verständnis notwendigen Inhalte über Screenreader zugänglich (52)
  • Kontakt zum Herausgeber für weitere Informationen zur Barrierefreiheit (99)