steps.add(new ClassWithMethodsAandB());
steps.add(new ClassWithMethodsCandD());
String stepsAsString = steps.toString(); // includes object ID numbers
// from JVM
XStream xs = new XStream();
ScenarioType scenarioType = ScenarioType.NORMAL;
List<Step> subset = foo.collectBeforeOrAfterScenarioSteps(steps, null, Stage.BEFORE, scenarioType);
String subsetAsXML = xs.toXML(subset);
assertThat(subsetAsXML.indexOf("<name>a</name>"), greaterThan(-1)); // there
assertThat(subsetAsXML.indexOf("<name>b</name>"), equalTo(-1)); // not there
assertThat(subsetAsXML.indexOf("<name>c</name>"), greaterThan(-1)); // there
assertThat(subsetAsXML.indexOf("<name>d</name>"), equalTo(-1)); // not there
assertThat(subsetAsXML.indexOf("<name>a</name>"), lessThan(subsetAsXML.indexOf("<name>c</name>"))); // there
assertThat(stepsAsString, equalTo(steps.toString())); // steps have not been mutated.
subset = foo.collectBeforeOrAfterScenarioSteps(steps, null, Stage.AFTER, scenarioType);
subsetAsXML = xs.toXML(subset);
assertThat(subsetAsXML.indexOf("<name>a</name>"), equalTo(-1)); // not there
assertThat(subsetAsXML.indexOf("<name>b</name>"), greaterThan(-1)); // there
assertThat(subsetAsXML.indexOf("<name>c</name>"), equalTo(-1)); // not there
assertThat(subsetAsXML.indexOf("<name>d</name>"), greaterThan(-1)); // there
assertThat(subsetAsXML.indexOf("<name>d</name>"), lessThan(subsetAsXML.indexOf("<name>b</name>"))); // reverse order