Skip to content

Support JSON serialization with result model #4847

Closed

Description

@pekkaklarck

RF 6.1 added support to serialize the execution model (robot.running.TestSuite) into JSON and back (#3902). This support should be extended to the result model (robot.result.TestSuite) as well. Supporting writing results directly to a JSON file as part of execution is out of the scope of this issue (we already have #3423 about that), but Rebot should be able to produce output.json files.

A precondition for this issue is cleaning up the result model a bit. That includes removing deprecated attributes (#4846), enhancing how keyword names are stored (#4884) and enhancing timestamp handling (#4258).

Activity

  1. added this to the v7.0 milestone on Aug 25, 2023
  2. self-assigned this
    on Sep 29, 2023
  3. self-assigned this
    on Dec 18, 2023
  4. pekkaklarck commented on Dec 18, 2023

    @pekkaklarck
    MemberAuthor

    The ModelObject base class that both running and result objects use got to_json and from_json methods already in RF 6.1 when JSON serialization support was added to the running model (#3902). Supporting to_json and from_json with the result model had a precondition that the result model should be cleaned up a bit (see issues referenced from the description), and after that all result model objects just needed their own to_dict. @yanne has implemented them (relevant commits don't seem to be linked to this issue) and they were already part of RF 7.0 beta 1.

    The commit referenced above adds JSON support to Rebot so that both of these usages work:

    #  Convert output.xml to JSON:
    rebot --output output.json output.xml
    
    # Parse JSON output files:
    rebot output.json
    

    Notice that the created output.json file only contains information about the executed suite, no statistics or errors like output.xml files contain. We probably should change that in the future when we add support to write output.json as part of execution (#3423). Robot's own functions and tools processing output.json files will, however, continue to support also files with only suite information.

    This functionality still needs to be documented in the User Guide, but otherwise this issue is ready.

  5. pekkaklarck commented on Dec 19, 2023

    @pekkaklarck
    MemberAuthor

    The JSON data format has a separate section in the User Guide. A similar section would be nice for the JSON result format as well, but it would also be a bit odd because we don't have such a section for the XML result format. I think we can consider result formats such information that it isn't needed by normal users and thus doesn't need to be documented in the User Guide. We can add something later, but then we should document both XML and JSON formats.

    How to use create and process JSON output files with Rebot obviously needs to be documented.

  6. added a commit that references this issue on Jan 26, 2024
    126ea4c
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions