在本文中,我将介绍测试用方面实现的横切行为的一组技术。
In this article, I introduce a catalog of techniques for testing crosscutting behavior implemented with aspects.
相应地,下面两个模式展现了使用在AJDT这样的工具中提供的人工检测横切视图补充正常测试的好处。
Accordingly, the next two patterns show the benefits of supplementing normal tests with manual inspection of the crosscutting views available in tool such as AJDT.
随着AOP的普及,编写与横切关注点在目标系统中的实现无关的、对其进行检查的测试已变得可行并且值得去做。
With the popularization of AOP, it has become both possible and desirable to write tests that check crosscutting concerns independent of their realization in a target system.
可以利用这种关注点的分离分别测试横切规范及它们的行为。
You can leverage this separation of concerns to test their behavior separately from the crosscutting specification.
在完成这个例子的过程中,我将强调给定的测试模式是验证横切功能、规范,还是两者同时验证。
As I proceed with the examples, I'll highlight whether a given test pattern verifies the crosscutting functionality, the specification, or both.
横切数个类的行为给集成测试带来了一个特定问题。
Behavior that crosscuts a number of classes poses a particular problem for integration tests.
除了编译器以及编辑器之外,我们需要能够帮助我们推断系统,确定潜在横切关注点,以及能够帮助我们对所存在的方面进行测试的工具。
In addition to compilers and editors, we need tools to help us reason about systems, identify potential cross-cutting concerns, and help us test in the presence of aspects.
关于测试广泛分布的横切关注点的一个难题是它会报告太多的联结点。
One of the hard things about testing a widespread crosscutting concern is that it can advise so many join points.
不过,在面向方面编程(AOP)出现之前,为横切行为(如安全、事务管理或者持久性)编写测试很困难。
Prior to the advent of aspect-oriented programming (AOP), however, it was difficult to write certain kinds of tests for crosscutting behavior such as security, transaction management, or persistence.
这个模式对前一个模式做了补充,只是它测试方面的横切规范和上下文处理而不是横切行为。
This pattern complements the previous one, except that it tests the crosscutting specification and context-handling of the aspect rather than the crosscutting behavior.
不过,如果用方面实现横切行为,那么就有了测试(并理解)应用程序的横切关注点的新方法。
If you implement your crosscutting behavior with aspects, however, you gain new ways to test (and understand) your application's crosscutting concerns.
通过将一些逻辑从建议中分离到helper类中(或者方法中),可以编写与横切规范无关的、检查应用程序横切行为的测试。
By factoring some logic out of your advice and into a helper class (or method), you can write tests that check your application's crosscutting behavior independent of its crosscutting specification.
通过将一些逻辑从建议中分离到helper类中(或者方法中),可以编写与横切规范无关的、检查应用程序横切行为的测试。
By factoring some logic out of your advice and into a helper class (or method), you can write tests that check your application's crosscutting behavior independent of its crosscutting specification.
应用推荐