Skip to content

Instantly share code, notes, and snippets.

View schultzisaiah's full-sized avatar

Isaiah Schultz schultzisaiah

View GitHub Profile
@schultzisaiah
schultzisaiah / SPOCK.vtl
Last active July 9, 2025 21:30
TestMe (IntelliJ Plugin) macro for Mockito-free Spock tests
#parse("TestMe macros.groovy")
#set($mockableFields = [])
#foreach($field in $TESTED_CLASS.fields)
#if($MockitoMockBuilder.isMockable($field, $TESTED_CLASS))
#set($devNull = $mockableFields.add($field))
#end
#end
#set($hasMocks = !$mockableFields.isEmpty())
#if($PACKAGE_NAME)
@schultzisaiah
schultzisaiah / DataDogUtil.java
Last active January 17, 2025 21:30
Add to DataDog traces from Java code
import static java.lang.String.format;
import static java.util.Optional.ofNullable;
import com.fasterxml.jackson.databind.JsonNode;
import com.fasterxml.jackson.databind.ObjectMapper;
import datadog.trace.api.interceptor.MutableSpan;
import io.opentracing.Tracer;
import io.opentracing.util.GlobalTracer;
import java.util.Iterator;
import java.util.Map.Entry;
@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