Skip to Content
Maîtriser la brillance
book

Maîtriser la brillance

by Hadley Wickham
November 2024
Intermediate to advanced
372 pages
9h 2m
French
O'Reilly Media, Inc.
Content preview from Maîtriser la brillance

Chapitre 21. Les tests

Cet ouvrage a été traduit à l'aide de l'IA. Tes réactions et tes commentaires sont les bienvenus : translation-feedback@oreilly.com

Pour les applications simples, il est assez facile de se rappeler comment l'application est censée fonctionner, de sorte que lorsque tu apportes des modifications pour ajouter de nouvelles fonctions, tu ne brises pas accidentellement les capacités existantes. Cependant, lorsque ton application devient plus compliquée, il devient impossible de tout retenir simultanément dans ta tête. Le test est un moyen de capturer le comportement souhaité de ton code de manière à ce que tu puisses automatiquement vérifier qu'il continue à fonctionner comme tu le souhaites. Transformer tes tests informels existants en code est pénible lorsque tu le fais pour la première fois, car tu dois soigneusement transformer chaque pression de touche et chaque clic de souris en une ligne de code, mais une fois que c'est fait, il est beaucoup plus rapide de réexécuter tes tests.

Nous allons effectuer des tests automatisés avec le paquetage testthat. testthat nécessite de transformer ton application en paquetage, mais comme nous l'avons vu au chapitre 20, ce n'est pas trop de travail, et je pense que cela en vaut la peine pour d'autres raisons.

Un test qui ressemble à ceci :

test_that("as.vector() strips names", {
  x <- c(a = 1, b = 2)
  expect_equal(as.vector(x), c(1, 2))
})

Nous reviendrons très bientôt sur les détails, mais sachez qu'un test commence par une ...

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.

Read now

Unlock full access

More than 5,000 organizations count on O’Reilly

AirBnbBlueOriginElectronic ArtsHomeDepotNasdaqRakutenTata Consultancy Services

QuotationMarkO’Reilly covers everything we've got, with content to help us build a world-class technology community, upgrade the capabilities and competencies of our teams, and improve overall team performance as well as their engagement.
Julian F.
Head of Cybersecurity
QuotationMarkI wanted to learn C and C++, but it didn't click for me until I picked up an O'Reilly book. When I went on the O’Reilly platform, I was astonished to find all the books there, plus live events and sandboxes so you could play around with the technology.
Addison B.
Field Engineer
QuotationMarkI’ve been on the O’Reilly platform for more than eight years. I use a couple of learning platforms, but I'm on O'Reilly more than anybody else. When you're there, you start learning. I'm never disappointed.
Amir M.
Data Platform Tech Lead
QuotationMarkI'm always learning. So when I got on to O'Reilly, I was like a kid in a candy store. There are playlists. There are answers. There's on-demand training. It's worth its weight in gold, in terms of what it allows me to do.
Mark W.
Embedded Software Engineer

You might also like

실리콘밸리 리더십

실리콘밸리 리더십

김정혜, 마이클 롭
Aufbau sicherer und zuverlässiger Systeme

Aufbau sicherer und zuverlässiger Systeme

Heather Adkins, Betsy Beyer, Paul Blankinship, Piotr Lewandowski, Ana Oprea, Adam Stubblefield

Publisher Resources

ISBN: 9798341613607