IntelliJ IDEA. Writing Tests with Spock

In this screencast we're going to use the Spock framework for creating and running unit tests.
00:00 - Intro
00:10 - Creating a Project for Spock
01:15 - Setting up the Dependencies
03:17 - A Simple Assertion
06:26 - Given, When and Then
08:06 - Groovy Tips for Java Developers
09:33 - Label Flexibility
10:18 - Spock Plugin
10:58 - Expecting Exceptions
13:49 - Data Pipes
18:42 - Data Tables
21:30 - Mocks
25:45 - Stubs
28:36 - Helper Methods
30:35 - with()
31:33 - verifyAll()
32:27 - Setup and Teardown
34:18 - Specifications as Documentation
35:23 - Conclusion and More Information
*Author: Trisha Gee
For more information, go to:
github.com/trishagee/spock-te...
spockframework.org/spock/docs/...
Download IntelliJ IDEA: jb.gg/download-intellij-idea
Top 15 IntelliJ IDEA shortcuts: • Top 15 IntelliJ IDEA s...
Join us:
Website jb.gg/website
Blog jb.gg/blog
Twitter / intellijidea
Facebook / intellijidea
#intelliJIDEA #SpockFramework #intelliJ #jetbrains #Java #programming

Пікірлер: 50

  • @theLoneCodesman
    @theLoneCodesman3 жыл бұрын

    This is very helpful. I haven’t heard anything about Spock before, but this looks very interesting to try to incorporate into our development process.

  • @tylersharpe3600
    @tylersharpe36003 жыл бұрын

    Thanks Trisha. We've been using spock as our primary testing framework at work for years now, but I still learned some new things from this video (particularly the verifyAll() API and multi-cursor feature)!

  • @CarlMarcum
    @CarlMarcum3 жыл бұрын

    Thanks ! This was a great introduction to Spock.

  • @intellijidea

    @intellijidea

    3 жыл бұрын

    Glad you liked it!

  • @brianjohnsen3992
    @brianjohnsen39923 жыл бұрын

    Absolutely brilliant! I've been using (and teaching) Spock for years, and your video is beautifully precise and to the point. One itsy bitsy thing: at 32:15 you reintroduce the renderer (line 98) in the verifyAll-block, but since it has the same name as the variable (line 89) it will only assert that the variable is equal to itself. IDEA actually recognises that by highliting renderer.

  • @TrishaGee

    @TrishaGee

    3 жыл бұрын

    Yes!! Someone spotted the error! I didn't introduce it on purpose, I noticed it after I finished the screencast and published the code. But I was waiting to see who would spot it first. You win!

  • @wmv1990
    @wmv1990 Жыл бұрын

    If you are not able to view separately every test case run for a Data table or Data pipe created for a test method. Please add annotation @Unroll on top of the test method, so that feature gets activated for you by spock. This feature by default is present in newer spock versions but not in old ones. Thanks for the superb video!

  • @DJMightyChip
    @DJMightyChip3 жыл бұрын

    Oh my gods, Spock is still going strong?! Excellent. Hands down, my favourite testing framework. JUnit is trustworthy and dependable... but Spock lets you write tests in an intelligible way. Even non-technical people can understand many of these tests.

  • @Greatfulone
    @Greatfulone2 жыл бұрын

    I love some of the features like access to private fields, and the creating parametrized tests a lot easier. I feel my Groovy project is a bit slower in compiling and running then Maven. I don't have the fastest pc, but it is current. Oh, and thank you for content. It was exactly what I need to start and some more to work on for future.

  • @mayurravindra9433
    @mayurravindra94332 жыл бұрын

    Simply loved the tutorial! Very useful even to experienced devs. Kudos👍

  • @davidhsv2
    @davidhsv23 жыл бұрын

    This is great, way better than junit giant method names. Thank you for showing that

  • @intellijidea

    @intellijidea

    3 жыл бұрын

    Glad you like it!

  • @cvetkovicslobodan
    @cvetkovicslobodan10 ай бұрын

    Amazing presentation...nice job 👍

  • @mohsinraza3913
    @mohsinraza39133 жыл бұрын

    Great video (y) had this feeling right from the start :)

  • @shankarsg1405
    @shankarsg14053 жыл бұрын

    Thank you for the video 😊

  • @sergiopuccini
    @sergiopuccini2 жыл бұрын

    Great video. Saved my ass at new job :) Thanks!

  • @nikolaykaradzhov449
    @nikolaykaradzhov4493 жыл бұрын

    Thank you, great video

  • @intellijidea

    @intellijidea

    3 жыл бұрын

    Glad you liked it!

  • @mikeCavalle
    @mikeCavalle3 жыл бұрын

    what a great tutorial -- regards

  • @intellijidea

    @intellijidea

    3 жыл бұрын

    Many thanks!

  • @Greatfulone
    @Greatfulone2 жыл бұрын

    Thank you so much for the content. Can you do a follow up on debugging the unit tests. It seems like debugging and setting break points need a bit more code.

  • @ankxy1
    @ankxy13 жыл бұрын

    thanks this helps a lot

  • @intellijidea

    @intellijidea

    3 жыл бұрын

    Glad it helped

  • @StephanStan
    @StephanStan3 жыл бұрын

    To complete the tutorial - I need to add module that includes awt.Polygon, Using Openjdk11.

  • @TrishaGee

    @TrishaGee

    3 жыл бұрын

    You shouldn't have to, it shouldn't require any awt. You need to create a brand new Polygon class. See the code here: github.com/trishagee/spock-testing-demo/

  • @StephanStan

    @StephanStan

    3 жыл бұрын

    @@TrishaGee Thank you.

  • @fabasoad
    @fabasoad3 жыл бұрын

    Haven't heard about Spock before. I would like to try it in a real world project.

  • @TheGuroguro12
    @TheGuroguro12 Жыл бұрын

    thank u

  • @axelbrugger9944
    @axelbrugger9944 Жыл бұрын

    Nice. But you forgot to mention that when you first opened the Java project, you were showing the build.gradle file instead of the 'src' folder (there was bno way to see that you had the build.gradle file open)

  • 3 жыл бұрын

    Great presentation! Is there a way to annotate, it some other trick for the setup/cleanup methods to indicate they're part of spock? Right now IntelliJ gray them out like they're never called.

  • @TrishaGee

    @TrishaGee

    3 жыл бұрын

    Hmmm, interesting, IntelliJ IDEA should recognise them as test methods. Which version of IntelliJ IDEA are you using?

  • 3 жыл бұрын

    @@TrishaGee I'm on the latest and greatest 2020.3.1(Ultimate) but it's always been that way. It doesn't recognize any of the setup/cleanup methods as part of the spock infrastructure. They are all considered never called and grayed out.

  • @m1k0register
    @m1k0register2 жыл бұрын

    How to add more moving parts to a project? Swap JUnit for Spock ;)

  • @shawnmofid7131
    @shawnmofid71312 жыл бұрын

    How does Spock work with CI/CD? Does it work like Junit and maven sure fire?

  • @cya3mdirl158
    @cya3mdirl1583 жыл бұрын

    Please add better formatting support test method.

  • @TrishaGee

    @TrishaGee

    3 жыл бұрын

    Please feel free to request improvements/new features in the issue tracker: youtrack.jetbrains.com/issues/idea

  • @momos2899
    @momos28993 жыл бұрын

    is there a code Competition in java

  • @TheMateuszNH
    @TheMateuszNH2 жыл бұрын

    is there some other good materials ? This one is very good but doesn't help writing hard tests.

  • @SharebookBR
    @SharebookBR Жыл бұрын

    Excelent. Thanks!

  • @cya3mdirl158
    @cya3mdirl1583 жыл бұрын

    We are waiting for Spock 2.0...

  • @davidwidner8258
    @davidwidner82582 жыл бұрын

    Could not create the "polygon" object :\

  • @tharakakushan

    @tharakakushan

    2 жыл бұрын

    Polygon Has been created as concreate class inside the code base, the code base git link attached to the description also. Good Luck! @Neo.

  • @user-gc4nk5re4d
    @user-gc4nk5re4d Жыл бұрын

    建议添加spring spock的使用章节

  • @asit2303
    @asit23033 жыл бұрын

    😂

  • @strekozuka
    @strekozuka Жыл бұрын

    Hi, I have 'CannotCreateMockException' error and can't solve it. I'm doing everything for the tutorial. How does it solve?