Knowledge Base > Cover CLI > Cover Replay: Getting Started (Windows)
Cover Replay: Getting Started on Windows
This section shows how to use Cover Replay to record and extract tests for a demo project in Windows. You can also:
- Follow the instructions for Linux, macOS, and MinGW.
- Go back to the main Cover Replay documentation.
Before you start, please get the Cover CLI and unpack the release ZIP in C:\cover\
. If you unpack it elsewhere, please adapt steps 3 and 4 accordingly.
1. Get the project under test
Download the CoreBanking demo project and unzip it. Then compile it:
cd CoreBanking-replay-demo
mvn compile
mvn dependency:copy-dependencies
2. Run the application
The demo project has a batch application that processes bank transactions stored in .txt
files. Run it like this:
java -cp "target\classes;target\dependency\*" ^
io.diffblue.corebanking.ui.batch.BatchProcessor src\test\resources\batch\*.txt
This is an example from one of the input files (batch1.txt
):
CLIENT|James Brown
ACCOUNT|1234|James Brown|10
...
CASH|120000|2020-02-04|1234
CASH|-125|2020-02-05|1234
CASH|120000|2020-02-28|1234
...
3. Record the application
We now record the execution of this application using the Cover Replay agent. To do this, just execute the following script (if Cover is not unpacked in C:\cover\
, please amend line 4 of the script):
record.bat
The recording will be saved to a new folder within %userprofile%\.diffblue\rec\
. Learn more about recording by checking agent documentation or reading the comments inside the script.
4. Extract tests from the recording
Extract tests for one package:
C:\cover\dcover.bat create --trace --verbose io.diffblue.corebanking.compliance.rules
Option --trace
tells Cover to use the last recording to extract tests. Learn more about test extraction.
5. Inspect the created tests
Search for files named *DiffblueTest.java
in src\test\java\
. For instance, the test shown below (from src\test\java\io\diffblue\corebanking\compliance\rules\ComplianceRuleLargeCashDepositsDiffblueTest.java
) was extracted from your recording. Note the references to James Brown
and the CashTransaction
with the amount 120000L
, which we saw in step 2:
@Test
public void testValidateAccountCompliance2() throws AccountException {
// Arrange
Account account = new Account(1234L, new Client("James Brown"), 10L);
account.addTransaction(new CashTransaction(15L, new Date(1577836800000L), account));
account.addTransaction(new CashTransaction(120000L, new Date(1580774400000L), account));
account.addTransaction(new CashTransaction(-125L, new Date(1580860800000L), account));
account.addTransaction(new CashTransaction(120000L, new Date(1582848000000L), account));
ComplianceRuleLargeCashDeposits complianceRuleLargeCashDeposits =
new ComplianceRuleLargeCashDeposits();
// Act
complianceRuleLargeCashDeposits.validateAccountCompliance(account);
// Assert
assertEquals(1, complianceRuleLargeCashDeposits.getCompliantAccounts().size());
assertFalse(complianceRuleLargeCashDeposits.hasNonCompliantAccounts());
}