title: Insert attribute into List attribute in Java
body: <p>I have a doubt about an implementation which I don't know if is correct or I am committing a crime. I have a test class with 2 class attributes, a custom object and a List of these objects. For each test, the object is reset and inserted into the list and I think it is smell very bad. Is this correct or maybe it can cause problems to me?</p>
  <pre><code>public class TestingClass {
  
  private List&lt;CustomObject&gt; objects;
  
  private CustomObject object;
  
  @Before
  public void setUp() {
      objects = new ArrayList&lt;&gt;();
      object = new CustomObject();
  }
  
  @Test
  public void firstTest() {
      object.setProperty(&quot;n1&quot;);
      objects.add(object);
  
      assert(objects.get(0).getProperty().equals(&quot;n1&quot;);
  }
  </code></pre>
  <p>Thank you for your help!</p>