-
How I Create Test Objects in Java
2024-01-16 "The Problem When I write tests in Java, I find it tedious to manually create objects and setting attributes. Code easily turns out like this: var foo = new Foo("Satellite", 1000, true); var bar = new Bar("Edward", "Scissorhands", List.of(foo)); // do stuff assertEquals(foo, bar.findByName("Satellite")); Here we're first creating a Foo, which is then added to a Bar. We then test that we can find the Foo when we ask the Bar to search for it."