Skip to content

Instantly share code, notes, and snippets.

View schultzisaiah's full-sized avatar

Isaiah Schultz schultzisaiah

View GitHub Profile
@schultzisaiah
schultzisaiah / spock-cheat-sheet.md
Created May 11, 2022 16:41
Spock Testing: Overview and Cheat Sheet

Spock Testing

This is a copy/MD-conversion of the original article by Lukasz Janicki: Spock Testing – Spock tutorial – The Javatar . The webpage is no longer available, but this cheat-sheet is too good to loose! A simpler full demo of a Spock implementation can also be found here.

What is Spock?

Spock is a unit testing framework that in great extent utilizes Groovy’s syntax making your tests comprehensible and easy on the eyes. Although it is a Groovy technology you can use it to test your Java classes as well. What is the most important is that Spock makes writing tests fun. And I really mean it.

Why Spock?

I have to admit that even knowing all the benefits of TDD and tests over all I considered writing them as little pain in the neck. How has that changed when I started using Spock?

  1. Creating a test in Spock takes less time than using its sta
@schultzisaiah
schultzisaiah / auto-kill-process.sh
Created May 6, 2020 20:53
Auto kill a resource-hogging process
# AUTO-KILL iCoreService using more than 60% CPU
# run as super user (sudo ./auto-kill-process.sh)
while true
do
PID=$(ps aux | grep 'iCoreService' | grep -v grep | awk '{ if ($3 >= 60.0) { print $2 } }' | head -n 1)
if [ ! -z "$PID" ]
then
kill -9 $PID
date >> iCoreService-kills.log