简体   繁体   English

如何正确处理人类可读的结果?

[英]How to properly handle human-readable results?

I'm developing a testing suite based on Selenium 2. The goal is to test a series of pages under different situations (specified through an arbitrary XML file). 我正在开发基于Selenium 2的测试套件。目标是在不同情况下(通过任意XML文件指定)测试一系列页面。

The output is given through: 输出通过以下方式给出:

  • Some zipped screenshots 一些压缩的截图
  • A raw log file 原始日志文件
  • An html file 一个html文件

Right now the raw log file and the markdown log file (later used to generate the html) is generated through messages hardcoded in the app. 现在,原始日志文件和降价日志文件(后来用于生成html)是通过应用程序中的硬编码消息生成的。

Now I'm thinking of using some auxiliar data structures to contain every single piece of relevant info, using some kind of convention (codes, enums, etc.) to later process and present. 现在,我正在考虑使用一些辅助数据结构来包含每条相关信息,并使用某种约定(代码,枚举等)来稍后处理和呈现。 If I'm not wrong, this should make the code easier to mantain and less redundant. 如果我没有记错的话,这应该使代码更易于维护且减少冗余。

My question is: is there a better approach, or widely accepted practice, for this? 我的问题是:为此有更好的方法或广泛接受的做法吗?

As an example of how the output (just a scratch) is: 作为输出(只是刮擦)的示例:

<Test> | <name of page> | <browser>:
    * Searchbox found and query submitted
    * ERROR: timeout while waiting for results
<Test> | <name of page> | <browser>:
    * Question found and answer submitted
    * Alert box content: < ... >
    * OK

Thanks 谢谢

PS: if anybody fins a more suitable question title, it'll be more than welcome PS:如果有人找到一个更合适的问题标题,那将是非常受欢迎的

Edit 编辑

Sorry if my question isn't as concise as it should, I'm trying my best to make myself clear. 抱歉,如果我的问题不够简洁,我正在尽力使自己清楚。

In other words, when my program has to output a potentially big amount of text giving information about the result of the tests executed, how should I do it? 换句话说,当我的程序必须输出大量可能提供有关执行测试结果信息的文本时,我应该怎么做? hardcode the messages or use some auxiliar data structure (something like a queue/pile) that keeps track of what had happened since the start to the end of the execution (be it error and status codes, for example) and then process it compose a readable document? 对消息进行硬编码或使用一些辅助数据结构(例如队列/堆),以跟踪自执行开始到执行结束后发生的情况(例如,错误和状态代码),然后对其进行处理以构成一个可读的文件?

Using a presentation-independant data structure is obviously a better choice. 使用独立于表示的数据结构显然是更好的选择。 It allows 它允许

  • decoupling the testing from the reporting 将测试与报告分离
  • generating several kinds of reports (HTML, PDF, text, etc.) 生成多种报告(HTML,PDF,文本等)
  • internationalizing the reports 国际化报告
  • integrating the testing into another application which won't do any reporting, but present the result in some GUI component (a tree or a table for example) 将测试集成到另一个应用程序中,该应用程序不做任何报告,但是将结果显示在某些GUI组件中(例如,树或表)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM