JMockit Mocks Are Not Being Created
还没有人认领这个 Issue。
评估
调研方向
从 src/test/java/com/github/opticyclic/demo/assertj/SimpleFormTest.java 和链接的复现项目中的 GuiActionRunner.execute 调用开始。比较 executeInEDT 外部和内部的模拟行为,然后运行测试以确认按钮接收到的是 "Mock Button Text" 而不是 "Not Mocked"。
由索引模型根据 Issue 内容生成。
描述
I took the code example from here https://stackoverflow.com/questions/14375854/jmockit-and-fest-ui-testing and put it in a gradle project here https://github.com/opticyclic/assertj-swing-mocks
The test code inside the GuiActionRunner doesn't seem to get mocked even though the code outside it does.
@Override
protected void onSetUp() {
//Mock the Service
new Expectations() {{
service.getValue();
result = mockText;
}};
//Demonstrate that the mocking is working here
SimpleService simpleService = new SimpleService();
Assert.assertEquals(simpleService.getValue(), mockText);
JFrame frame = GuiActionRunner.execute(new GuiQuery<JFrame>() {
@Override
protected JFrame executeInEDT() {
SimpleController controller = new SimpleController();
JFrame frame = new JFrame("Simple Frame");
frame.add(controller.getPanel());
frame.setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
frame.pack();
return frame;
}
});
The test fails with:
java.lang.AssertionError: [javax.swing.JButton[name='testButton', text='Not Mocked', enabled=true, visible=true, showing=true] - property:'text']
Expecting:
"Not Mocked"
to match pattern:
"Mock Button Text"
Why are the mocks not being created?
- 主要语言
- Java
- 星标
- 121
- 派生
- 52
- PR 合并指标
- 30 天内没有已合并 PR
环境准备
- 没有 Dockerfile 或 Docker Compose 文件
- 没有 Pull Request 模板
- 阅读贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
assertj/assertj-swing 的其他 Issue
-
难度 3/5 半天 新手友好度 35/100
assertj/assertj-swing#281 ·
-
难度 5/5 一周以上 新手友好度 25/100
assertj/assertj-swing#279 ·
-
难度 2/5 1-3 小时 新手友好度 48/100
assertj/assertj-swing#278 · 1 条评论 ·
-
难度 4/5 3-5 天 新手友好度 30/100
assertj/assertj-swing#276 · 1 条评论 ·
-
Update unit test to avoid deprecated `ExpectedException.none()` by using `Assert.assertThrows()`未关闭
难度 4/5 3-5 天 新手友好度 35/100
assertj/assertj-swing#275 ·
查看 assertj/assertj-swing 的全部 Issue
相似的 Issue
-
[BUG] S3 CORS responses omit Access-Control-Allow-Credentials for matched origins可能已有人在做 关联的 PR 仍在进行中或已合并。 未关闭
难度 2/5 1-3 小时 新手友好度 72/100
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 72/100
sqlcipher/sqlcipher-android#97 · 1 条评论 ·
-
area-integrations
难度 2/5 1-3 小时 新手友好度 68/100
维护者通常 1 天内回复
-
bug IIIF interoperability
难度 2/5 1-3 小时 新手友好度 72/100
-
难度 2/5 1-3 小时 新手友好度 72/100