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
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.
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)!
Thanks ! This was a great introduction to Spock.
@intellijidea
3 жыл бұрын
Glad you liked it!
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
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!
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!
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.
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.
Simply loved the tutorial! Very useful even to experienced devs. Kudos👍
This is great, way better than junit giant method names. Thank you for showing that
@intellijidea
3 жыл бұрын
Glad you like it!
Amazing presentation...nice job 👍
Great video (y) had this feeling right from the start :)
Thank you for the video 😊
Great video. Saved my ass at new job :) Thanks!
Thank you, great video
@intellijidea
3 жыл бұрын
Glad you liked it!
what a great tutorial -- regards
@intellijidea
3 жыл бұрын
Many thanks!
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.
thanks this helps a lot
@intellijidea
3 жыл бұрын
Glad it helped
To complete the tutorial - I need to add module that includes awt.Polygon, Using Openjdk11.
@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
3 жыл бұрын
@@TrishaGee Thank you.
Haven't heard about Spock before. I would like to try it in a real world project.
thank u
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)
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
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.
How to add more moving parts to a project? Swap JUnit for Spock ;)
How does Spock work with CI/CD? Does it work like Junit and maven sure fire?
Please add better formatting support test method.
@TrishaGee
3 жыл бұрын
Please feel free to request improvements/new features in the issue tracker: youtrack.jetbrains.com/issues/idea
is there a code Competition in java
is there some other good materials ? This one is very good but doesn't help writing hard tests.
Excelent. Thanks!
We are waiting for Spock 2.0...
Could not create the "polygon" object :\
@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.
建议添加spring spock的使用章节
😂
Hi, I have 'CannotCreateMockException' error and can't solve it. I'm doing everything for the tutorial. How does it solve?