Back to Basics: Testing in C++ - Phil Nash - CppCon 2023

  Рет қаралды 7,500

CppCon

CppCon

3 ай бұрын

cppcon.org/
---
Back to Basics: Testing in C++ - Phil Nash - CppCon 2023
github.com/CppCon/CppCon2023
If we’re writing tests for our code we probably think we should write more - or write better tests. If we’re not already writing tests perhaps we think we should start. Or perhaps we are not, yet, convinced they are worth it?
This session will introduce you to the benefits of testing and how to get started and be effective.
We’ll look at:
* What does testing even mean?
* What types of testing are there, and what should I focus on?
* Should I use a test framework? If so which one?
* What are the testing best practices?
* What are some common challenges and pitfalls to overcome?
---
Phil Nash
Phil is the original author of the C++ test framework, Catch2, and composable command line parser, Clara. As Developer Advocate at Sonar he's involved with SonarQube, SonarLint and SonarCloud, particularly in the context of C++. He's also a member of the ISO C++ standards committee, organiser of C++ London and C++ on Sea, as well as co-host and producer of CppCast. More generally he's an advocate for good testing practices, TDD and using the type system and functional techniques to reduce complexity and increase correctness. He's previously worked in Finance and Mobile offers training and coaching in C++ and TDD.
---
Videos Filmed & Edited by Bash Films: www.BashFilms.com
KZbin Channel Managed by Digital Medium Ltd: events.digital-medium.co.uk
---
Registration for CppCon: cppcon.org/registration/
#cppcon #cppprogramming #cpp

Пікірлер: 9
@steptoevs996
@steptoevs996 3 ай бұрын
I think the only reason some Developers do not write test, it is because of the overhead of installing dependencies of that or this Framework. C++ still annoying to manage dependencies.
@kuhluhOG
@kuhluhOG 26 күн бұрын
8:10 Personally I always find integration tests considerably harder to write (and more time consuming to write in total) than unit tests. I also consider integration tests in general more important than unit tests, because while most units you would unit test are small and simple enough that you can (mostly) make sure that they work by looking at it (and if it isn't, a unit test normally isn't that hard to write, even without a test framework), that doesn't hold for integration tests (let alone even system tests).
@TheOnlyAndreySotnikov
@TheOnlyAndreySotnikov 3 ай бұрын
42:39 in my 30+ years of development experience I've never seen methods like size()/SIze()/length()... were responsible for any kind of bugs. Unfortunately, 90% of unit tests are that level useless.
@organichand-pickedfree-ran1463
@organichand-pickedfree-ran1463 3 ай бұрын
Is it possible to test for compilation errors these days? Like proper SFINAE use etc. Last time I checked it was impossible to do negative tests for some compile-time things.
@kingduckVI
@kingduckVI 2 ай бұрын
In short: No, it is not really possible. The closest you can get is testing if a concept (C++20) is false, which will test if a certain expression/statement is valid given certain types.
@KX36
@KX36 3 ай бұрын
45:30 I don't think "arrange, assert precondition, act, assert postcondition" is a bad thing, and I might argue it is a single logical assertion as long as the asserts are checking the same thing pre and post action. After all, you don't want to waste time debugging an action that failed its assert because the precondition is not what was expected.
@not_ever
@not_ever 3 ай бұрын
That was the point of using sections though. You can clearly define the precondition so if it fails its easier to see at a glance from the test output that your precondition is the problem and when you/others are reading your tests the delimination between pre and post conditions is clear.
@doBobro
@doBobro 3 ай бұрын
"Classical" unit tests are quite damaging for industry concept. Basically it forces you to write enormous amount of testing code and dance with "isolation". Forces you to rewrite enormous amount of code during refactorings (tests doesn't work as refactoring-aid tool) and internal details changes (fragile tests). It's hardly surprising developers don't like to write unit tests.
@TheOnlyAndreySotnikov
@TheOnlyAndreySotnikov 3 ай бұрын
Also, most unit tests look like this: "auto sqrt(auto x) { return 2; } ASSERT_EQ(2, sqrt(4));" In 90% of companies, unit testing is a cargo cult.
OMG 😨 Era o tênis dela 🤬
00:19
Polar em português
Рет қаралды 9 МЛН
Разбудила маму🙀@KOTVITSKY TG:👉🏼great_hustle
00:11
МишАня
Рет қаралды 3,9 МЛН
Super sport🤯
00:15
Lexa_Merin
Рет қаралды 19 МЛН
ROS ステアリング台車テスト
1:56
ロボット動画集
Рет қаралды 239
Fluent Assertions in Unit Testing in C#
10:09
IAmTimCorey
Рет қаралды 10 М.
THIS stops 90% of C# Developers Learning TDD
19:40
Gui Ferreira
Рет қаралды 12 М.
The standard library now has all you need for advanced routing in Go.
13:52
C++ Weekly - Ep 425 - Using string_view, span, and Pointers Safely!
8:36
C++ Weekly With Jason Turner
Рет қаралды 10 М.
Power up all cell phones.
0:17
JL FUNNY SHORTS
Рет қаралды 48 МЛН
Apple, как вас уделал Тюменский бренд CaseGuru? Конец удивил #caseguru #кейсгуру #наушники
0:54
CaseGuru / Наушники / Пылесосы / Смарт-часы /
Рет қаралды 4,3 МЛН
🤔Почему Samsung ПОМОГАЕТ Apple?
0:48
Technodeus
Рет қаралды 433 М.
The power button can never be pressed!!
0:57
Maker Y
Рет қаралды 52 МЛН
How charged your battery?
0:14
V.A. show / Магика
Рет қаралды 1,9 МЛН
Introducing GPT-4o
26:13
OpenAI
Рет қаралды 4,4 МЛН