every time while writing the test cases i need to write all the object constructors and setters manually for ex:
Pojo.java
public class Pojo {
private int a;
private int b;
private int c;
// getters and setters
// equals and hashCode
// toString
}
PojoTest.java
//@SpringBootTest
@RunWith(SpringRunner.class)
public class PojoTest {
@Autowired
private Pojo p;
@Test
public void getValues() {
p.setA(1);
p.setB(2);
assertEquals(p.getA(),1);
}
}
here if you look at this below code manually writing the setters
p.setA(1);
p.setB(2);
is there any plugin to auto fill the Args based on data types in intelliJ?
You can use instancio library for automating data setup in unit tests.
Instancio uses reflection to populate objects, including nested objects and collections. A single method call provides you with a fully populated instance of a class, ready to be used as an input to your test case
MVN Dependency:
Example:
Reference: https://www.instancio.org/