简体   繁体   中英

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).

The output is given through:

  • Some zipped screenshots
  • A raw log file
  • An html file

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.

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

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.)
  • 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)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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