-
Notifications
You must be signed in to change notification settings - Fork 17
Testing Rules
ozangunalp edited this page Aug 2, 2018
·
5 revisions
See latest version in maven central.
Maven
<!-- The dependency for doov-assertions -->
<dependency>
<groupId>io.doov</groupId>
<artifactId>doov-assertions</artifactId>
<version>LATEST</version>
</dependency>
<!-- The dependency on your generated DSL -->
<dependency>
<groupId>io.doov</groupId>
<artifactId>doov-sample-generated</artifactId>
<version>1.0-SNAPSHOT</version>
</dependency>
Gradle
dependencies {
compile group: 'io.doov', name: 'doov-assertions', version: '2.+'
compile project(':doov-sample-generated')
}
This documentation is based on the sample project in
dOOv. You can replace
the package name io.doov.sample
by your package name as com.example.myapp
and classes name Sample
with MyApp
.
The dOOv assertions depends on AssertJ, so you can use the assertThat
syntax with fluent test assertions.
package io.doov.sample.validation;
import static io.doov.assertions.Assertions.assertThat;
import static io.doov.sample.validation.SampleRules.RULE_EMAIL;
public interface SampleRulesTest {
private Model model;
private ModelWrapper modelWrapper;
@Before
public void before() {
Account account = new Account();
account.setEmail("account@email.com");
model = new Model();
model.setAccount(account);
modelWrapper = new ModelWrapper(model);
}
@Test
public void test() {
assertThat(RULE_EMAIL).validates(modelWrapper)
.hasFailureCause("")
.isFalse();
}
}
Finished :-)