So the old code in your tests looked like this for starting Scassandra:
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
private static PrimingClient primingClient; | |
private static ActivityClient activityClient; | |
private static Scassandra scassandra; | |
@BeforeClass | |
public static void startScassandraServer() throws Exception { | |
scassandra = ScassandraFactory.createServer(); | |
scassandra.start(); | |
primingClient = scassandra.primingClient(); | |
activityClient = scassandra.activityClient(); | |
} |
This for stopping Scassandra:
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@AfterClass | |
public static void shutdown() { | |
scassandra.stop(); | |
} |
And this for resetting Scassandra between tests:
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@Before | |
public void setup() { | |
activityClient.clearAllRecordedActivity(); | |
primingClient.clearAllPrimes(); | |
} |
Now you can simply do this:
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@ClassRule | |
public static final ScassandraServerRule scassandra = new ScassandraServerRule(); | |
@Rule | |
public final ScassandraServerRule resetScassandra = scassandra; | |
private static PrimingClient primingClient = scassandra.primingClient(); | |
private static ActivityClient activityClient = scassandra.activityClient(); |
Assigning it to a ClassRule means that it will start Scassandra before all your tests and stop it after all your tests. Then assigning it to a regular Rule means that the Activity client and Priming client will be reset between tests.
No comments:
Post a Comment