我需要重构我的Selenium测试,并且想知道对于具有分层页面组织的门户来说,最好的设计解决方案是什么。我们正在使用瓷砖,并且我们已经定义了一个baselayout,许多页面都是从它继承的。
考虑以下简化示例:
更好的是,基于继承的设计:
/** Implements methods that access the top-level menu. */
Class BaseLayout {...}
/** Implements methods that access elements of the "Start" page */
Class StartPage extends Base Layout {...}
/** Implements methods that access elements of the "About" page */
Class AboutPage extends Base Layout {...}还是基于聚合的设计?:
/** Implements methods that access the top-level menu. */
Class BaseLayout {...}
/** Implements methods that access elements of the "Start" page */
Class StartPage {
BaseLayout parent;
// ...
}
/** Implements methods that access elements of the "About" page */
Class AboutPage {
BaseLayout parent;
// ...
}当我遇到可加载构件设计模式时,出现了这个问题,因为Selenium已经为这些组件提供了一个抽象类,因此第一个基于继承的解决方案是不可行的。
发布于 2011-07-26 15:13:36
我使用的是基于继承的设计。它工作得很好,直到我正在测试的应用程序也可以在另一个更有限的面向客户的UI中使用。所以现在我有两个应用程序,它们由相同的组件组成,被不同的菜单包围。在这种情况下,继承的设计会中断。
我想,基于聚合的设计与一些IOC容器相结合可能会更加灵活。
https://sqa.stackexchange.com/questions/1497
复制相似问题