C++ Unit Testing with Google Test Tutorial

  Рет қаралды 395,396

JetBrains

JetBrains

8 жыл бұрын

In this tutorial, we take a look at how to perform using testing in C++ using the Google Test framework and ReSharper C++ as the test runner. To find out more about ReSharper C++, please visit:
www.jetbrains.com/resharper-cpp
Author: Dmitri Nesteruk

Пікірлер: 84
@KangJangkrik
@KangJangkrik 3 жыл бұрын
The moment you realized JetBrains didn't "dog food" their C++ IDE on this tutorial
@jflopezfernandez
@jflopezfernandez 6 жыл бұрын
This was an amazing tutorial. Would love to see another one specifically with any nuances in CLion or maybe some for advanced features, but this was great, thank you
@syntaxusdogmata3333
@syntaxusdogmata3333 8 жыл бұрын
7:09 - Great example of parameterized testing in Google Test.
@baqtronic7704
@baqtronic7704 5 жыл бұрын
Awesome step-by-step! Thank you very much!
@MrBasania
@MrBasania 5 жыл бұрын
ReSharper seems to be a great extension, the refactoring features are much more advanced comparing to the ones that VS has.
@ihspan6892
@ihspan6892 2 жыл бұрын
Thank you, very clear and straightforward.
@arthurspa
@arthurspa 4 жыл бұрын
Really good example of how to use gtest.
@johngalt7704
@johngalt7704 4 жыл бұрын
Большое спасибо за проделанную работу!
@placeforpeace1562
@placeforpeace1562 5 жыл бұрын
i got error in the INSTANTIATE_TESTCASE_P like function definition not found . what do i do now;
@patrickhentschel5300
@patrickhentschel5300 7 жыл бұрын
only opens some text in the console for me, not in Visual Studio. Did i miss something?
@zenoncelofan5768
@zenoncelofan5768 4 жыл бұрын
Historical note: Before February 2016 *_EQ had a convention of calling it as ASSERT_EQ(expected, actual), so lots of existing code uses this order. Now (2020) *_EQ treats both parameters in the same way. However, when possible, ASSERT_EQ(actual, expected) is preferred. (gtests docs)
@zianaris2150
@zianaris2150 6 жыл бұрын
Good one. Please do another video for gmock.
@dmanikhine
@dmanikhine 3 жыл бұрын
Коротко и по делу. Огромное спасибо автору!
@venkateswarans1012
@venkateswarans1012 4 жыл бұрын
Best way to do this in Linux
@mathssoso4261
@mathssoso4261 2 жыл бұрын
Could you just explain how did you create the base project, stdafx.h and targetver.h, I can't make this compile, vs can't find the test in test explorer
@rocky6162
@rocky6162 3 жыл бұрын
why set the field to a pointer (BankAccount*) instead of just the object itself at 4:56?
@RollerBladingSports
@RollerBladingSports Жыл бұрын
Without pointer you'll call it by value, but you should call it by reference. hope this one is still actual :D
@thegod3500
@thegod3500 7 жыл бұрын
What is unit test session page in your VS, and where i can find its?
@dariadovzhikova418
@dariadovzhikova418 7 жыл бұрын
This is ReSharper Unit Test Session tool window (www.jetbrains.com/help/resharper/2016.2/Using_Unit_Test_Sessions.html) If you have ReSharper and/or ReSharper C++ installed it should be available in ReSharper | Windows | Unit Test Sessions.
@advaitharmy
@advaitharmy 6 жыл бұрын
When I try to add "account_state {100, 50, 50, true}",I am getting error "expected '(' for function-style cast or type construction". Can any one help me?
@nastasiak2512
@nastasiak2512 6 жыл бұрын
Could you share a full sample? Where do you get the error btw? In the IDE or during the compilation?
@smajin28
@smajin28 2 жыл бұрын
0:40 Already on it. This is what I want to know. Where did he earn this stuff. How could I have possibly known to do that without this video. This all had to start somewhere.
@andriykuz1140
@andriykuz1140 8 жыл бұрын
Hi, I have such error when running tests: 'Can't run "path" --gtest_list_tests" witch working directory "path": Can't create process'. Maybe someone meet this error?
@olgarodygina5127
@olgarodygina5127 8 жыл бұрын
+Andriy Kuz Could you please download and install the latest ReSharper Release 2016.1 and check if the issue is still present for you? If it won't help could you please send to me some sample solution with this issue to olga.rodygina at jetbrains dot com? Thank you!
@theycallmemorphine
@theycallmemorphine 3 жыл бұрын
Does anyone know whats the version of the latest Google test
@renekomane
@renekomane 5 жыл бұрын
Is it possible to using googletest and C++ to run automation test on chrome ? Like insert an user and psw in a web page a login automatically ?
@JetBrainsTV
@JetBrainsTV 5 жыл бұрын
Hello Alexander, thank you for contacting us. With ReSharper C++ you could run google tests inside Visual Studio: www.jetbrains.com/help/resharper/Unit_Testing_in_CPP.html Thank you!
@sharathmanchala6571
@sharathmanchala6571 4 жыл бұрын
very useful for beginners
@wenyangzhao6026
@wenyangzhao6026 8 жыл бұрын
why not CLion?
@soloondotnet
@soloondotnet 8 жыл бұрын
+Wenyang Zhao Google Test support in CLion is coming, too!
@placeforpeace1562
@placeforpeace1562 5 жыл бұрын
could u please give the actual source code of this video
@ductamnguyen8257
@ductamnguyen8257 4 жыл бұрын
what is the shortcut keyboard to generate the constructor ?? Can anyone help me with that? Thank you
@JetBrainsTV
@JetBrainsTV 4 жыл бұрын
Maybe this will help - www.jetbrains.com/help/resharper/Code_Generation__Type_Constructors.html
@decky1990
@decky1990 Жыл бұрын
Why would you use Google Test over asserts or static_asserts?
@Bill-gc9bt
@Bill-gc9bt 5 жыл бұрын
I understand that you're a genius at this stuff, but can you provide a reference for those of us that are new to google test? You know, where every single detail (no matter how small you think it is) is thoroughly explained. Feel free to tell me that I'm a lost cause, if that is indeed the case. Thanks in advance.
@hitarthmukundraykanakia3137
@hitarthmukundraykanakia3137 4 жыл бұрын
Is this present in Clion?
@viorelcasapu9951
@viorelcasapu9951 6 жыл бұрын
nice video. Could you make a video about unit testing using also mock files? it will be great
@olgarodygina5127
@olgarodygina5127 6 жыл бұрын
Hello Viorel! Thank you for feedback. We will consider such possibility. Thank you!
@kpanat
@kpanat 7 ай бұрын
As I remember this is in Qt,isn't it? So I don't forget all else...
@deadsoul181
@deadsoul181 3 жыл бұрын
Дима а можно по-русски?
@helloworld8583
@helloworld8583 4 жыл бұрын
Thank you!!!!!!!!!!! =*) Спасибочки! Дякую!
@ksenichiro5417
@ksenichiro5417 5 жыл бұрын
Спасибо за ролик, хороший английский, кстати
@pectusin
@pectusin Жыл бұрын
I'm not surprised, Dmitri gradated from University of Southampton, UK ))
@rituexplorer
@rituexplorer 3 жыл бұрын
Please make a video on mocking free functions
@TroyBreaker
@TroyBreaker 9 ай бұрын
Спасибо, но что делать, если мой класс в отдельном .h файле?
@kpanat
@kpanat 7 ай бұрын
Here all fields are public. But how test privatr fields?
@ignacioswboada660
@ignacioswboada660 2 жыл бұрын
Link to the code of the video?
@stana.281
@stana.281 4 жыл бұрын
0:10 - And if you're not using Visual Studio?
@ivanenzhaev2373
@ivanenzhaev2373 3 жыл бұрын
I use QtCreator IDE. You can setup GTest and GMock very quickly: 1) Select "File" > "New Project" > "Other Project" > "Auto Test Project". 2) Next, in drop down list ("Test framework") select "Google Test". Choose the source code folder of Google Test (that you get from GithUb) for example: "E:\Libs\googletest-release-1.10.0". Google Mock will be included too.
@ali57555
@ali57555 Жыл бұрын
We need a Clion tutorial please
@skell1
@skell1 5 жыл бұрын
How come we aren't using CLion? If C++ was included in the features for Resharper, I would have bought that instead. Sigh.
@KangJangkrik
@KangJangkrik 3 жыл бұрын
Would be better if you move the definitions into header file
@chenyangliu9120
@chenyangliu9120 2 жыл бұрын
I wonder how it ran without return value for BankAccount::withdraw
@chenyangliu9120
@chenyangliu9120 2 жыл бұрын
I mean at first, this bool function without a return should cause the program compiling into Error
@jdleanne
@jdleanne 3 жыл бұрын
can we have an updated version?
@JetBrainsTV
@JetBrainsTV 3 жыл бұрын
We'll definitely plan updating the content. However, except for the UI, not many things changed.
@jdleanne
@jdleanne 3 жыл бұрын
@@JetBrainsTV yes please. Most videos. Including the paid ones are out dated :(
@Roanoked
@Roanoked Жыл бұрын
"if you use visual studio" ... no, I'm using a CMake based project structure with CLion 😅
@jeensdeleted
@jeensdeleted Жыл бұрын
Unclear how to get this "NuGet Packages" =/
@rishabhagarwal3404
@rishabhagarwal3404 5 жыл бұрын
If anyone is having issue with installation and writing basic test. I have added a guide to installation with some sample code. github.com/rishabh-agarwal/googleTestDemo Hope this helps
@spicytuna08
@spicytuna08 6 жыл бұрын
why not use class instead of struct?
@reysabs
@reysabs 5 жыл бұрын
Mostly in C++ use struct if you can to avoid possible memory leak cause struct is a valued type and it was manage by OS that means you dont need to release or delete.
@GuyCollinsWilliam
@GuyCollinsWilliam 5 жыл бұрын
I was thinking exactly the same thing.
@m3tsAEp31kk0
@m3tsAEp31kk0 5 жыл бұрын
@@reysabs I don't know where you're getting your "information" but that is not correct. Structs work exactly like classes except for the default visibility of members.
@reysabs
@reysabs 5 жыл бұрын
Im sorry I was referring for creating a Data structure. I used C++ for cross platform mobile development. IOS prefer struct over Class on this matters. I only use Class for methods or anything needs inheritance cause C#, Swift and Java doest support multiple inheritance.
@HermanWillems
@HermanWillems 5 жыл бұрын
I got a more important question: Why people use inheritance so much. It breaks encapsulation. Use composition as much as possible. People are thought wrongly in the past.
@dinobulja
@dinobulja 3 жыл бұрын
19 errors at the start already, not compiling Severity Code Description Project File Line Suppression State Error C4996 'std::tr1': warning STL4002: The non-Standard std::tr1 namespace and TR1-only machinery are deprecated and will be REMOVED. You can define _SILENCE_TR1_NAMESPACE_DEPRECATION_WARNING to acknowledge that you have received this warning. ExploreGoogleTest \\folderredirect\frrp-data02\ki0v\desktop\work\cpp\exploregoogletest\packages\googletest.1.8.3\build ative\include\gtest\gtest-printers.h 632
@abdullahakcam9550
@abdullahakcam9550 3 жыл бұрын
Did you find a solution?
@dinobulja
@dinobulja 3 жыл бұрын
@@abdullahakcam9550 nope
@aminbe3079
@aminbe3079 6 жыл бұрын
I don't understand the point of unit testing anyway, why not just compile your program the normal way and test it ?!
@prezadent1
@prezadent1 6 жыл бұрын
The tests are for future use so when you make changes the tests can verify that the results are still valid.
@Hypersion
@Hypersion 6 жыл бұрын
Imagine you have a program with 10 Millions lines of code written by dozens of different people and you want to add or change a feature or fix a bug. How do you do that and make sure you don't break the rest of the code base. Simple, you use tests.
@jayands
@jayands 5 жыл бұрын
Tests are for when you go to modify the code. If you didn't write it, or even if you did but some time ago, you can look at it and see that this is what is supposed to happen. Combined with code coverage, it can eliminate a ton of bugs before they get released, both subtle and glaring. As an oversimplified example, ever been to r/GamePhysics on Reddit? Ideally, those could have been caught with unit and behavior testing
@spicytuna08
@spicytuna08 6 жыл бұрын
lol. test code is 100 times longer/complicated than actual code. it takes more brain to write test code than actual code.
@MistahJuicyBoy
@MistahJuicyBoy 5 жыл бұрын
80% (at least for me) of writing code is debugging, and writing test code cuts into that time.
@gabrielmalek7575
@gabrielmalek7575 Жыл бұрын
Please use dark mode, my eyes are on fire
@huyvole9724
@huyvole9724 4 жыл бұрын
So fast
@Eminosrrr
@Eminosrrr 6 жыл бұрын
hard german accent
@markgraham2312
@markgraham2312 6 жыл бұрын
This video is an advertisement for resharper. Unit Tests are not done like this at all. Unit Tests test source code. There is no source code here. Just code created for the unit test.
@lorenzosauvaire7314
@lorenzosauvaire7314 6 жыл бұрын
so tdd ?
Introduction to Google Test and CMake
31:32
Rhymu's Videos
Рет қаралды 132 М.
Test-Driven Development // Fun TDD Introduction with JavaScript
12:55
Шокирующая Речь Выпускника 😳📽️@CarrolltonTexas
00:43
Глеб Рандалайнен
Рет қаралды 11 МЛН
DELETE TOXICITY = 5 LEGENDARY STARR DROPS!
02:20
Brawl Stars
Рет қаралды 10 МЛН
UFC 302 : Махачев VS Порье
02:54
Setanta Sports UFC
Рет қаралды 1,4 МЛН
Be kind🤝
00:22
ISSEI / いっせい
Рет қаралды 23 МЛН
Do you even test? (your code with CMake)
12:38
Code for yourself
Рет қаралды 17 М.
A Tour of Modern C++
1:05:46
JetBrains
Рет қаралды 137 М.
Unit Tests and Test Doubles like Mocks, Stubs & Fakes
17:32
Cognitive Programmer
Рет қаралды 130 М.
C++ testing with mocks is EASY and awesome!
10:00
Smok Code
Рет қаралды 18 М.
Thoughts About Unit Testing | Prime Reacts
11:21
ThePrimeTime
Рет қаралды 205 М.
Project Setup: Automated Testing with Make (using queue example)
17:00
C# Unit Testing - Full Course - Write Unit Tests in C# like a pro!
1:22:12
tutorialsEU - C#
Рет қаралды 39 М.
31 nooby C++ habits you need to ditch
16:18
mCoding
Рет қаралды 723 М.
Самый топовый ПК без RGB подсветки
1:00
CompShop Shorts
Рет қаралды 83 М.
iPhone 15 Unboxing Paper diy
0:57
Cute Fay
Рет қаралды 2,8 МЛН
Эффект Карбонаро и бумажный телефон
1:01
История одного вокалиста
Рет қаралды 2,8 МЛН
Задача APPLE сделать iPHONE НЕРЕМОНТОПРИГОДНЫМ
0:57
iPhone 15 Pro vs Samsung s24🤣 #shorts
0:10
Tech Tonics
Рет қаралды 12 МЛН