使用JUnit测试GUI [英] Testing GUI with JUnit
问题描述
嗯,我们都知道测试驱动的开发。我需要编写一个基于GUI的库,但说实话,我总是忽略测试。 JUnit是否适用于大学等等,但我们从来没有比通常更深入的实施列表并测试它。
Well, we all know test-driven development. I'd need to write a GUI-based library, but to be honest, I always neglected the testing. Did JUnit for university and such, but we never got any deeper than the usual "Implement a list and test it."
所以,因为我不想写我想知道,有哪些功能的应用程序,使用Scala和JUnit进行基于GUI的库测试的专业方法是什么?
So, since I don't want to write a thousand applications for the features, I'd like to know, what's the "professional" approach to GUI-based library testing with Scala and JUnit?
感谢收听。
推荐答案
将您的表现层与其他所有内容分开。
Separate your Presentation layer from everything else.
保持Presentation层尽可能薄,以便理论上测试可以在给定模式的中间人中进行; MVC,MVVM等...
Keep the Presentation layer as thin as possible so that testing can in theory take place within a middle-man of a given pattern; MVC, MVVM, etc...
当你开始将表层与基础逻辑耦合时,你的测试将成为维护和执行的噩梦。
The moment you begin to couple the Presentation layer with underlying logic your testing will become a nightmare to maintain as well as execute.
在彻底测试您的模型/ ViewModel /控制器等结束时...测试表示层通常会失去其备受推崇的价值。它还有价值吗?是的......但回报大幅减少。
At the end of thoroughly testing your Models/ViewModels/Controllers, etc...testing the Presentation layer can often times lose its highly regarded value. Is it still valuable? Yes...but the return has diminished considerably.
这些概念适用于许多框架/语言。一旦掌握了这种理解,给定框架/语言的技术优势就会自然浮现出来。不要依赖框架/语言来回答这个问题。框架/语言肯定能够以更友好的方式提供关注点分离,但关注点的分离始终是任何类型测试的最前沿;包括GUI。
These concepts apply to many frameworks/languages. Once you grasp this understanding the technological benefits of a given framework/language will surface naturally. Do not rely on the framework/language to answer this though. A framework/language can definitely lend itself to provide separation of concerns in a much more friendly manner however the separation of concerns is and has always been at the forefront of any type of testing; GUI included.
这篇关于使用JUnit测试GUI的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!