mercredi 16 décembre 2015

Request new singleton bean "WebDriver" between each @Test scope

How can I receive a new bean between each @Test?

Example:

public class Person(){
 private String name = "bob";
 //getters //setters
}

public Class MyTest(){
  @Autowired
  private Person person;

 @Test
 public void firstName(){
   person.setName = "Peter";
   system.out.println(person.getName());
   (Should print out Peter)
 }

 @Test
 public void firstNameTest2(){
   system.out.println(person.getName());
   (Should be reset and print bob)
}

I've been using @DirtiesContext(classMode = ClassMode.ON_TEST_METHOD) As a TestClass Annotation, however, this is horrible.. my other frameworks re-init between each test... and slows everything down by a full minute.

I've tried to configure custom scope, and I implemented the Spring Listeners... I reset my Person Bean after each test method... However, that only works at the class level, it doesn't give me a new Person object between @Test scopes.

Thank you, let me know if you need more code to clarify.

Aucun commentaire:

Enregistrer un commentaire