集成测试和Junit [英] Integration test and Junit

查看:78
本文介绍了集成测试和Junit的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

你好,

我已经有一些针对Java代码的集成测试,我想知道是否有任何方法可以检测每个集成测试的源和目标,例如,如果我们有两个组件A和B,那么当组件A调用组件B时,应该有一个集成测试来同时测试这两个组件,并且当组件B调用组件A时,我们应该进行另一个集成测试,我的问题是从测试用例中我们可以确定哪个组件是调用方,哪个被调用方取决于集成使用工具或特定的库自动测试代码.

Hello,

I have already some integration tests for java code, I''m wondering if there is any way to detect the source and the target of each integration test, for example if we have two components A and B, when component A calls component B we should have an integration test to test these two components together, and when component B calls component A we should have another integration test, my question is from the test cases can we decide which component is the caller and which was the callee depends on the integration test code automatically, by using tool or specific libraries.

推荐答案

AFAIK无法从外部查看调用堆栈.一旦进入方法,就可以获取调用堆栈:
AFAIK there is no way to externally view the call stack. Once inside a method you can get the call stack thus:
StackTraceElement[] stackTraceElements = Thread.currentThread().getStackTrace();


我不确定这是否对您有帮助,因为您希望检查是否调用了所有方法.

我建议采用两种方法进行测试;这是我雇用并工作的东西.

首先进行单元测试.这应该是白盒子",测试人员知道被调用的内容并创建覆盖所有路径的测试;或尽可能多.

其次是集成测试.这是一个黑匣子"测试,验证该软件是否能够交付预期的结果.这通常是从UI的角度来看,并且可以自动进行以实现可靠的再现.

除此之外,如果该应用程序经历多个发行版,则将进行回归测试.确保应用程序在进行任何更改之前仍能执行其操作.


I am not sure this will help you as you wish to check that all methods are called.

I would suggest a two pronged approach to testing; this is something I have employed and works.

Firstly unit test. This should be ''white box'', the tester knows what is being called and creates tests to cover all the paths; or as many as are practical.

Secondly integration test. This is a ''black box'' test, validate that the software is delivering what is expected. This will often be from the UI point of view and can be automated for reliable reproduction.

In addition to this, if the application goes through several releases, is regression testing. Ensure the application still do what it was doing prior to any changes.


这篇关于集成测试和Junit的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆