Plugin to create runtime variable instance builder

Asked

Viewed 30 times

1

I need to create some tests using variables already instantiated at runtime, and instead of manually mounting, object by object, attribute by attribute, I would like some tool that automates this and already brings the code with the filled objects and variables, this tool exists in Intellij?

For example, just dragging the Watch variable into the code, I would like you to bring the valued objects. Are many objects and attributes that have to fill, causing a waste of time.

inserir a descrição da imagem aqui

  • You want a tool inside the Intellij IDEA that fills with random values any class in the middle of the code debug?

1 answer

0

For example, just dragging the Watch variable into the code, I would like you to bring the valued objects

Intellij IDEA itself does not provide such a resource, and in my view it would not make much sense for your unit test, given the start of your question:

I need to create some tests using variables already instantiated in execution time, and instead of mounting manually, object by object, attribute by attribute, would like some tool that automates itself that and already brought the code with the filled objects and variables

From what I understand, you actually need a tool in your unit test to fill classes with random values, so you don’t have to manually populate each one.

A library that can help you is the PRUNING:

// Simplest scenario. Will delegate to Podam all decisions
PodamFactory factory = new PodamFactoryImpl();

// This will use constructor with minimum arguments and
// then setters to populate POJO
Pojo myPojo = factory.manufacturePojo(Pojo.class);

// This will use constructor with maximum arguments and
// then setters to populate POJO
Pojo myPojo2 = factory.manufacturePojoWithFullData(Pojo.class);

// If object instance is already available,
// Podam can fill it with random data
Pojo myPojo3 = MyFactory.getPojoInstance();
factory.populatePojo(myPojo3);

There are others also. But the idea is to solve this problem before executing its unit test.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.