This is basically the question asked here. Yes, I’d say this is really the only way to do unit testing right now. There is a possibility we’ll add better fixture support here.
Your other alternative is to use functional testing via TestKit for this and embed your assertions in an actual task.
@Managed
interface Person {
String getName()
void setName(String s)
}
class Rules extends RuleSource {
@Model
void person(Person p) { }
@Mutate
void testRule(Person p) {
p.name = 'Bob'
}
}
apply plugin: Rules
model {
tasks {
assertModel(Task) {
doLast {
assert $.person.name == 'Bob'
}
}
}
}