Skip to content

Instantly share code, notes, and snippets.

View DominikMostek's full-sized avatar

Dominik Moštěk DominikMostek

View GitHub Profile
void inputOutputExample() {
Iterable<String> inputData = Arrays.asList("a", "b", ...);
String result = processor.process(input)
assertThat(result).isEqualTo("expected");
}
void dataAreStoredInMap() {
DataReader reader = new DummyReader("key1,value1", "key2,value2");
processor.process(reader);
// ...
}
@Test(expected = IllegalArgumentException.class)
void someTest() {...}
void moreAssert() {
assertThat(price.getTax()).isEqualTo(456);
assertThat(price.getVipDiscount()).isTrue();
}
assertThat(timeInSeconds).isEqualTo(object.getValue() * 2 * MINUTES);
// vs.
assertThat(timeInSeconds).isEqualTo(2_500);
@Test
public void shouldNavigateToPhotosPage() {
String baseUrl = "http://plus.google.com/";
Navigator nav = new Navigator(baseUrl);
nav.goToPhotosPage();
assertEquals(baseUrl + "/u/0/photos", nav.getCurrentUrl());
}
void variablesInInputStringAreReplacedByTheirValues() {...}
void exceptionIsThrownWhenVariableIsNotFound() {...}
void variableCanBeOverwritenInChildContext() {...}
void parametersCannotBeOverwritenInChildContext() {...}
void builderThrowExceptionWhenRegisteringVariableWithSameNameAsParameter() {...}
// ... etc
void variablesInInputStringAreReplacedByTheirValues() {...}
void exceptionIsThrownWhenVariableIsNotFound() {...}
void variableCanBeOverwritenInChildContext() {...}
void parametersCannotBeOverwritenInChildContext() {...}
void builderThrowExceptionWhenRegisteringVariableWithSameNameAsParameter() {...}
// ... etc
void testAdd() {...}
void testCalculation() {...}
void throwsException() {...}
void testRemove() {...}
// don’t do this
DateTimeUtils.setCurrentMillisFixed(millis);
// or this
ReflectionUtils.setField(service, "fieldName", fieldValue);