dimanche 21 février 2016

Unit or Acceptance test?

Imagine I have the following class structures:

public interface Sender {
   void send(String note);
} 

public interface Agent {
   void sendNote(String note);
}

public class Emailer implements Sender {
    void send(String note) {
       //...do something
    }
}

public class Helper {
    List<String> populateNotes() {
        //...do something
    }
}

public class EmailAgent implements Agent {
   List<String> notes;

   void sendNote(String note) {
      Helper helper = new Helper();
      notes = helper.populateNotes();
      for (String s : notes) {
           Sender sender = new Emailer();
           sender.send(s);
      }

   }
}

Now, I want to unit test the sendNote() method in EmailAgent. However, there is a dependency on Helper as it needs to populate the list notes. If in the JUnit test I first call populateNotes() before calling sendNote()...

  1. Is this a unit test or acceptance test?
  2. Or should I hard coded the list?

Aucun commentaire:

Enregistrer un commentaire