Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

What to expect for the future of the FixtureFactory? #115

Open
flaviolsousa opened this issue Jul 4, 2020 · 3 comments
Open

What to expect for the future of the FixtureFactory? #115

flaviolsousa opened this issue Jul 4, 2020 · 3 comments

Comments

@flaviolsousa
Copy link

flaviolsousa commented Jul 4, 2020

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.

  1. Update the source code to Java11
    mvn test its only working on Java8 and it is broke on Java11

  2. Support to local variable type inference (var) on from/gimme
    We inform the class on from method of FixtureFacture, 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
  1. The Processors are useful and already working on all situations. But, to simplify, if a class that implements TemplateLoader also implements the Processor interface, the execute 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 😅)

  2. 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
}}
  1. It would be very useful to have a way to use the regex or random 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 using FixtureFacture.

  2. Phenomenal the instant("18 years ago") feature. But don't works with LocalDate and LocalDateTime.
    Ok ... it's easy to solve like with LocalDate.now().minusYears(30). But it is strange to break the execution

  3. 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.

@flaviolsousa flaviolsousa changed the title Is a tool deprecated? What to expect for the future of the FixtureFactory? Jul 4, 2020
@mvpcortes
Copy link

Hello Flavio.

At 2015~ the fixture-factory was the best tool to make fixture. But I think with java9+ and lombok, we can use constructor with all arguments or set* methods with chain pattern.

I understand fixture-factory has more features, but I do not like the Rule class, I think it expensive and does take new java improviments.

Perhaps new fixture-factory should use a new sintax using the new java9+ o kotlin syntax.

@aravindraveendran7
Copy link

Hello @flaviolsousa ,I am using fixture factory to setup test data for API testing. How can I add dynamic data to a template? For instance, the response of a request should be fed into the template dynamically so that this template can be used to pass as a request to the following endpoint.

@nykolaslima
Copy link
Member

nykolaslima commented Sep 16, 2022

@flaviolsousa Im back to Java into a new project that I am working in and I saw the problem with Fixture Factory not working with Java11+.

I found the solution updating ASM dependency version used by paranamer: paul-hammant/paranamer#34

I will try to get back to Fixture Factory and see if we could update the project to support the later java versions

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants