Griffon 集成测试或显示 Griffon 视图的脚本
当我创建平面 java Swing 组件(例如对话框等)时,很容易进行单元测试来显示对话框。基本上,我可以创建对话框的实例并调用 setIsVisible(true)。我很难弄清楚如何使用狮鹫视图来做到这一点。我一直在尝试通过集成测试来做到这一点,但我似乎无法做到。
我尝试了一些方法来显示视图,但似乎没有任何效果。我似乎能够获取视图实例的唯一方法是: AirplaneView view = helper.newInstance(app, griffonpractice.AirplaneView.class, "Airplane")
在此之后我想我也许可以做 view.setIsVisible(true) 或 view.frame .setIsVisible(true)
但没有运气。我猜我以错误的方式思考这个问题,必须有一个相当简单的方法来做到这一点。任何帮助表示赞赏。我的视图如下所示,请注意,没有绑定,因此我不需要模拟任何内容。
package griffonpractice
import javax.swing.JFrame
JFrame frame = application(title: 'GriffonPractice',
size: [320,480],
pack: true,
location: [50,50],
locationByPlatform:true){
borderLayout()
{
hbox(constraints: BL.NORTH)
{
label(text: "shane")
label(text: "Jack");
}
}
}
When I create plane java Swing components like dialog boxes etc, it is very easy to make a unit test to display the Dialog. Basically, I can just create an instance of the dialog and call setIsVisible(true). I'm having a really tough time figuring out how to do this with a griffon View. I've been trying to do this with integration tests but I can't seem to get it.
I've tried a few things to show the view and nothing seems to work. The only way I seem to be able to get an instance of the view is:AirplaneView view = helper.newInstance(app, griffonpractice.AirplaneView.class, "Airplane")
After this I thought I may be able to do a view.setIsVisible(true) or view.frame.setIsVisible(true)
but no luck. I'm guessing I am thinking about this the wrong way, there has to be a fairly simple way to do this. Any help is appreciated. My view looks like the following, note that there are no bindings so I shouldn't need to mock anything.
package griffonpractice
import javax.swing.JFrame
JFrame frame = application(title: 'GriffonPractice',
size: [320,480],
pack: true,
location: [50,50],
locationByPlatform:true){
borderLayout()
{
hbox(constraints: BL.NORTH)
{
label(text: "shane")
label(text: "Jack");
}
}
}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您尝试过使用 FEST 吗? http://easytesting.org
这本书Griffon in Action有使用 FEST 测试 Griffon 应用程序的详细示例,源代码位于 http://code.google.com/p/griffoninaction/source/browse/trunk/chap09/dictionary
下面是一个简单应用程序的 3 个测试的简短示例
Have you tried using FEST? http://easytesting.org
The book Griffon in Action has a detailed example on testing a Griffon application using FEST, the source code is available at http://code.google.com/p/griffoninaction/source/browse/trunk/chap09/dictionary
Here's a short example of 3 tests for a simple application