Description
The fixture-factory is deprecated?
I really like the tool... but it is not having upgrades.
In fact, I noticed that there has been no commit for 14 months.
Should I continue using it in my projects?
Below is a list of improvements that I propose and could help to develop.
-
Update the source code to Java11
mvn test
its only working on Java8 and it is broke on Java11 -
Support to
local variable type inference
(var) on from/gimme
We inform the class onfrom
method ofFixtureFacture
, so I imagine something like this:
private <T> T fromExample(Class<T> clazz) {
if (String.class.equals(clazz))
return (T) "Test";
if (Integer.class.equals(clazz))
return (T) Integer.valueOf(12);
return null;
}
@Test
public void testGenerics() {
var str = fromExample(String.class); // ###
System.out.println(str.substring(0, 3));
var num = fromExample(Integer.class); // ###
System.out.println(num / 2);
}
Output:
Tes
6
-
The
Processors
are useful and already working on all situations. But, to simplify, if a class that implementsTemplateLoader
also implements theProcessor
interface, theexecute
method could be executed when generating the instances.
Or the Rule class can have a method postConstruct that I can override (I think I prefer this option)
Or another way would be to create a postConstruct annotation like Spring does (This I don't know how to do 😅) -
The
"prefix-${name}"
feature is greatting. But it is not possible to do this with instances of other types (non String)
- There could be a function similar like gimmeReference (" client.adress ")`
that returns the instance of an object in another property. - But the best solution, in my opinion, would be for FixtureFactory to support Function / Predicate or any other interface for anonymous functions that generate value:
new Rule() {{
add("locator", regex("[A-Z0-9]{6}"));
add("branchId", random(Long.class, range(1L, 100L)));
add("code", o -> o.getBranchId().toString() + o.locator().replace("[A-Z]", "")); // here
add("corporateId", o -> Integer.valueOf(o.getBranchId().toString().charAt(0))); // and here
}}
-
It would be very useful to have a way to use the
regex
orrandom
function directly from the test (outside the template) ... for primitive types there is no example of how to do it.
I needed this to generate queryParameters and custom headers. But I didn't find any example usingFixtureFacture
. -
Phenomenal the
instant("18 years ago")
feature. But don't works withLocalDate
andLocalDateTime
.
Ok ... it's easy to solve like withLocalDate.now().minusYears(30)
. But it is strange to break the execution -
When I do something wrong 😇, the exception thrown does not inform the attribute name, it only tells the reason.
The items are in the order I remembered ...
Congratulations for tool ... I'm putting it on all my projects (at CVC Corp), I don't see anything like what you created anywhere.
Tell me what you think about the list items. If you liked the suggestions, and will continue to support the tool, I can try to help.