Skip to content

Instantly share code, notes, and snippets.

View richashworth's full-sized avatar

Richard Ashworth richashworth

View GitHub Profile
@richashworth
richashworth / ResultsWriter.java
Last active June 28, 2020 15:07
Used as Class Under Test in PowerMock Example
package com.richashworth.powermockexample;
import java.util.List;
public class ResultsWriter {
public String getDataAsString(){
StringBuilder builder = new StringBuilder();
List<String> dataList = DataProvider.getData();
for(String str: dataList){
@richashworth
richashworth / DataProvider.java
Last active October 1, 2015 19:18
Used as dependency in PowerMock Example
package com.richashworth.powermockexample;
import java.io.File;
import java.io.IOException;
import java.nio.charset.Charset;
import java.util.List;
import static com.google.common.io.Files.readLines;
public final class DataProvider {
@richashworth
richashworth / DefaultValues.java
Last active September 29, 2015 02:58
Default Values Class
package com.richashworth.testingutils.mocking;
import java.util.HashMap;
import java.util.Map;
public class DefaultValues {
private Map<String, Object> defaultValuesMap;
public DefaultValues() {
@richashworth
richashworth / MockObjectPopulator.java
Last active September 16, 2016 13:25
Mock Object Populator
package com.richashworth.testingutils.mocking;
import java.lang.reflect.Method;
import java.util.Map;
import static org.junit.Assert.fail;
public class MockObjectPopulator {
private DefaultValues defaultValues = new DefaultValues();
@richashworth
richashworth / Footballer.java
Last active September 29, 2015 01:07
Used in Example to Demonstrate Naive Initialisation of Mock Object
package com.richashworth.testingutils.mocking;
public class Footballer {
private String name;
private int age;
private Double salary;
private Integer gamesPlayed;
private Integer goalsScored;
private Boolean isCaptain;