Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Proposal: Reporter support #268

Open
TwitchBronBron opened this issue Feb 9, 2024 · 1 comment
Open

Proposal: Reporter support #268

TwitchBronBron opened this issue Feb 9, 2024 · 1 comment

Comments

@TwitchBronBron
Copy link
Member

This describes custom reporter support in rooibos.

  1. Deprecate reporter in favor of reporters. Internally copy reporter value into reporters so it's backwards compatible. reporters will be an array of reporter factory functions (or class name).

bsconfig.json

{
    "rooibos": {
        "reporters": [
           "JUnit",
          "MyNamespace_MyCustomReporter",
           "happyReporter"
        ]
    }
}
  1. The rooibos runtime will now support multiple reporters. Each string name in the reporters list will be the name of a function that is a reporter factory (which also will support class names too since those are technically factories anyway). These reporters are created ONCE, at the start of the entire test run. These reporters much confirm to the following structure: Each method is optional.
  • onBegin - called at the very start of the testing process.
  • beforeSuite - called before the first test in each @suite
  • beforeDescribe - called before the first test in each @describe block
  • beforeIt - called before each @it() test. If the test is parameterized, will be called once for each parameterized combo. To help better reporting with parameterized tests, will include some form of isParameterized and index so you can report a header at the start of a parameterized @it group.
  • afterIt - called after each @it. Same rules as beforeIt
  • afterDescribe - called after the final test in this @describe block finishes
  • afterSuite - called after the final test in this @suite finishes
  • onEnd - called when the entire testing process is finished

Here's an example reporter factory:

```brighterscript
function happyReporter()
    return {
        onBegin: function(event)
            print "About to run your first rooibos test!"
        end function
        beforeSuite: function(event)
            print "before run suite " event.suite.name
        end function
        beforeDescribe: function(event)
            print "before run describe " event.describe.name
        end function
        beforeIt: function(event)
            print "before run it " event.it.name
        end function
        afterIt: function(event)
            print "after run it " event.it.name
        end function
        afterDescribe: function(event)
            print "after run describe " event.describe.name
        end function
        afterSuite: function(event)
            print "before run suite " event.suite.name
        end function
        onEnd: function(event)
            print "Yay, tests are done"
        end function
    }
end function
  1. The internals of rooibos will need to revise how reporting is done. We haven't flushed out the specific interfaces for the callback event structures.
@luis-soares-sky
Copy link
Contributor

Just so it isn't forgotten, these reporters will need to be supported in node tests as well.

Unless you're thinking of revamping how node tests report their results (as I think they're self-reporting right now), the easiest way I can think of is to have an option to add custom .bs imports for the rooibos-generated nodes.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants