arquillian-extension-persistence
arquillian-extension-persistence copied to clipboard
Support for regex expression in expected datasets
example:
expected-users-regex.yml
useraccount:
- id: "regex:\\d+"
firstname: regex:^Jo.* #John
lastname: regex:.*ith$ #Smith
username: regex:.oovd. #doovde
password: password
openDate: regex:^(?:[0-9]{2})?[0-9]{2}-[0-3]?[0-9]-[0-3]?[0-9]$
the test:
@Test
@ShouldMatchDataSet("expected-users-regex.yml")
public void should_verify_database_content_using_regex_in_expected_dataset() {
UserAccount ua = new UserAccount();
ua.setFirstName("John");
ua.setUserName("doovde");
ua.setOpenDate(newDate());
entityManager.persist(ua);
}
The main motivation is to deal with dynamic data in datasets. Here in the example is the Id which is generated by JPA and openDate.
Although it helps in some cases in most of the cases we have 'controlled' static data in datasets so I think if we add this feature it should come disabled.
What do you think?
I would appreciate the "regex:" -possibility using Arquillian integration testing !