Skip to content

Fixture-Factory 2.2.0

Compare
Choose a tag to compare
@nykolaslima nykolaslima released this 25 Apr 21:17
· 103 commits to master since this release

Features

  • Fixtures can now define Processors that will run after object instantiation. We already provide a HibernateProcessor to load generated fixtures into database, making easy to create integration tests
    Fixture.from(User.class).uses(new HibernateProcessor(session)).gimme("valid"); //this will generate new User based on valid template and insert it to database through Hibernate
  • Now we have TemplateLoader interface that should be used to declare or templates.
public class UserTemplateLoader implements TemplateLoader {
  @Override
  public void load() {
    Fixture.of(User.class).addTemplate("valid", new Rule() {{
      add("name", random("Nykolas", "Anderson", "Arthur"));
      ...
    }});
  }
}

And to load declared templates, we have the new class FixtureFactoryLoader that loads all templates in declared package
FixtureFactoryLoader.loadTemplates("br.com.six2six.template");

  • New random function to BigDecimal and BigInteger
    add("ammount", random(BigDecimal.class, new MathContext(2)));
  • Support to override properties definitions on gimme call #41
Client client = Fixture.from(User.class).gimme("valid", new Rule() {{
  add("name", "New name only for this client");
}});

Bugfixes

  • Prioritise default constructor and choose right constructor based on parameter name and type #32
  • Bugfix for attributes on inherited classes #35
  • Reset property on inherited template #38
  • Generate random values for short and byte #41
  • And others...