spring - Inject different values of enum for Junit test -


i have autowired bean defined in class want test:

@autowired contextenum mycontext; 

which used later:

if(contextenum.a.equals(mycontext)) { // } else if(contextenum.b.equals(mycontext)) { // } 

in config junits have set return specific value of contextenum, so:

@configuration @lazy public class myjunitconfig {     @bean     public contextenum getcontextenum() {        return contextenum.a;     } } 

my junit:

@runwith(springjunit4classrunner.class) @contextconfiguration(classes = {     myjunitconfig.class }) public class contexttest {    @test   public void testcontextb() {       input input = createmock(input.class);       expect(input.getid()).return(1l).anytimes();       client.gethandle().call();   } } 

however, doesn't allow me test different values of enum. there way me inject different enum values outside of using setter/constructor injection on junit? in advance.

use @theories in conjunction spring's testcontextmanager


Comments

Popular posts from this blog

android - Get AccessToken using signpost OAuth without opening a browser (Two legged Oauth) -

org.mockito.exceptions.misusing.InvalidUseOfMatchersException: mockito -

google shop client API returns 400 bad request error while adding an item -