Skip to content

Instantly share code, notes, and snippets.

View mariuszs's full-sized avatar

Mariusz Smykuła mariuszs

View GitHub Profile
#!/usr/bin/env bash
# Formatting constants
BOLD=`tput bold`
UNDERLINE_ON=`tput smul`
UNDERLINE_OFF=`tput rmul`
TEXT_BLACK=`tput setaf 0`
TEXT_RED=`tput setaf 1`
TEXT_GREEN=`tput setaf 2`
TEXT_YELLOW=`tput setaf 3`
@mariuszs
mariuszs / FooBarTest.java
Created January 21, 2014 20:37
Fragile test
import org.junit.Rule;
import org.junit.Test;
import org.junit.rules.ExpectedException;
import java.util.Arrays;
import java.util.List;
public class FooBarTest {
@Rule
@mariuszs
mariuszs / FooBarTest.java
Last active January 4, 2016 00:49
BDD Style Catch Exception
import org.junit.Test;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import static com.googlecode.catchexception.CatchException.caughtException;
import static com.googlecode.catchexception.apis.CatchExceptionAssertJ.then;
import static com.googlecode.catchexception.apis.CatchExceptionAssertJ.when;
@mariuszs
mariuszs / cow.fish
Created January 2, 2014 19:57
Fishshell random cowsay
fortune -s | cowsay -f (cowsay -l | tail -n +2 | tr ' ' '\n' | shuf -n 1)
_______________
/ Universe, n.: \
| |
\ The problem. /
---------------
\ ^___^
\ (ooo)\_______
@mariuszs
mariuszs / XTest.java
Last active December 29, 2015 08:39
Testing Logback Logger
Solution without PowerMock
--
import ch.qos.logback.classic.*;
import ch.qos.logback.classic.spi.LoggingEvent;
import ch.qos.logback.core.Appender;
import org.junit.*;
import org.junit.runner.RunWith;
import org.mockito.*;
import org.mockito.runners.MockitoJUnitRunner;
@mariuszs
mariuszs / FooTest.java
Created November 15, 2013 20:16
Checking for 2 expected values in Junit
import org.junit.Test;
import static com.googlecode.catchexception.CatchException.caughtException;
import static com.googlecode.catchexception.apis.CatchExceptionBdd.then;
import static com.googlecode.catchexception.apis.CatchExceptionBdd.when;
public class SomeTest {
SomeService foo;
@mariuszs
mariuszs / SomeServiceTest.java
Last active December 28, 2015 10:58
BDD Style expect exception for JUnit
import org.junit.Test;
import static com.googlecode.catchexception.CatchException.caughtException;
import static com.googlecode.catchexception.apis.CatchExceptionBdd.then;
import static com.googlecode.catchexception.apis.CatchExceptionBdd.when;
public class SomeServiceTest {
@Test
public void testDoThat() {
@mariuszs
mariuszs / MyTest.java
Last active December 28, 2015 10:49
Mockito + Catch Exception + Fest Assertion 2 - BDD Style!
import org.junit.Test;
import static com.googlecode.catchexception.CatchException.caughtException;
import static com.googlecode.catchexception.apis.CatchExceptionBdd.then;
import static com.googlecode.catchexception.apis.CatchExceptionBdd.when;
import static org.mockito.BDDMockito.given;
public class SomeServiceTest {
private SomeService myMock;
@mariuszs
mariuszs / MyTest.java
Last active March 19, 2024 10:08
Mockito + Catch Exception + AssertJ - BDD Style!
import com.googlecode.catchexception.MyException;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.InjectMocks;
import org.mockito.Mock;
import org.mockito.junit.MockitoJUnitRunner;
import static com.googlecode.catchexception.apis.BDDCatchException.caughtException;
import static com.googlecode.catchexception.apis.BDDCatchException.when;
import static org.assertj.core.api.BDDAssertions.then;
@mariuszs
mariuszs / gist:7474626
Created November 14, 2013 21:27
GPG Key
-----BEGIN PGP PUBLIC KEY BLOCK-----
Version: GnuPG v1.4.15 (GNU/Linux)
mQINBFKFPiYBEADBlrIGwiTARKzRt1AjcQgfyQvKYmBmFyTZWqXafm+TPWN59ZZO
Jon98Q0GWqOtKDUDW1nWdaARgxhCgaPSqcqreaegcFHmUe34+/bhEErx3tMkQBQk
n2OMUe7admnyoO8nLFf6NFisY/0hTjOXHkUcuqZ6McBSljAEkjdSZZ8W2ccP0WFb
oTPJf7AbAypD2AsmZO7kF+RcGZxbIYe0tROiM1WHjtdAjL33G8hssfPhMQp3M8BK
STXsPO57nBt6UB23f+Lo6adBFs6SdkmoSDKVGDA08CKTUDgxJX/C6bpbmYY0ZdCA
iVZbZr5PpZK7IlkGLTfqc2iKPjlkdJjoaT6UZiYZD7qNTEmjwcHsf8YD646vp/e+
NVyZskMPqLZ+0hDJ1cUP3YsYpwozS7VGZ2FEF1ygHBfemEshkBWlXnKL5syzRU61