mercredi 4 juillet 2018

How to correctly instantiate object from the class you are testing in JUnit 5 in a before hook?

@Before
public void setUp() {
    Airport airport = new Airport();
}
@Test
public void has_storage(){
    ArrayList<String> airport_storage;
    airport_storage = new ArrayList<String>();
    airport_storage.add("plane");
    ArrayList<String> actual_storage = airport.storage();

I am trying to test my airport class with the class AirportTest. Similar to RSpec/Jasmine and a few other testing frameworks I have used I want to make sure I get a new instance of the object for each test. Although I have read that instance variables will not persist across tests anyway in JUnit, so this may not be necessary. Why am I getting an error that the compiler cannot resolve symbol airport? How to correctly declare and initialise the instance of airport so that is in the scope of each @Test?

Thanks

Aucun commentaire:

Enregistrer un commentaire