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

加了测试参数后的代码,编译会报错 #17

Open
shjqk opened this issue May 25, 2019 · 2 comments
Open

加了测试参数后的代码,编译会报错 #17

shjqk opened this issue May 25, 2019 · 2 comments

Comments

@shjqk
Copy link

shjqk commented May 25, 2019

站点中的ProgramConstructureTest类
加了测试参数后的代码,编译会报错
@test
public void test2(@mocked HelloJMockit helloJMockit /* 这是一个测试参数 */) {
// 录制(Record)
new Expectations() {
{
helloJMockit.sayHello();

// Error:(40, 17) java: 从内部类中访问本地变量helloJMockit; 需要被声明为最终类型

@hzdavid
Copy link
Owner

hzdavid commented May 28, 2019

@shjqk 啥意思? ProgramConstructureTest.java 编译会报错? 并不会呀。

@xhwuh
Copy link

xhwuh commented May 30, 2019

new Expectations() {
{
{
helloJMockit.sayHello();
}
}

少两个大括弧,表示该匿名类的初始化代码块。

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

3 participants