Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

如何将mockup实例注入@Tested注解的实例中 #32

Open
529259265 opened this issue Feb 16, 2020 · 1 comment
Open

如何将mockup实例注入@Tested注解的实例中 #32

529259265 opened this issue Feb 16, 2020 · 1 comment

Comments

@529259265
Copy link

我要测试的类中有一个非静态变量,它调用了另一个类的方法,而被调用的这个类存在静态代码块。我考虑用mockup解决。同时我要测试的类需要调用一个接口,我使用了@Injectable注解这个接口实例,并用@tested标注这个被测类。那么如何将mockup实例也注入@tested的实例中呢

@AlbertNie
Copy link

不用考虑怎么去将 mockUp 实例注入到 @tested 实例中, 你只需要在 @tested 实例创建之前执行 new MockUp 即可, 比如写在静态代码块中 static{ new MockUp() }

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants