So far, only execution events for suites and suite collections are available.
Will ones for test cases and test steps be available in future releases? or Is there a way that I could somehow create them on my own?
if you mean by this that the listeners are scoped only to suites/collections you are right, and i see no reason for the listener class to be extended to testcase/step level, since imho those are just small individual pieces intended to be put totgheter in at least a suite to achieve some sort of reuseable/repetable automated test.
but if for some reaseon you need that a snippet of code to be executed before/after some testcases, but not all of them, or as you mentioned before/after certain steps, you can simply endorse them in separate testcases(e.g. make a folder with ācommonā scripts) per needs, and use the ācallTestCaseā feature where do you feel is needed, that way you can do prety modular design for your project
TBH, what Iām trying to achieve should be at listener layer since it has nothing to do with my test cases. To be more specific, after each test step/test case/test suite, I want to send a specific request for test step/test case/test suite to my report server.
@BeforeTestCase
? Thatās already available.
Yep, I do that with @afterTestCase
. But youāll also need to trap all errors and markFailed
calls. I do that by wrapping my TCs in a try-catch
.
as thomas detailed, for testcase level is already provided (but scoped to suite). as for the test step level ā¦ i hope you realise that a āstepā is in fact just a line of code from a script in katalon design ā¦
I do that too. I have āmini-suitesā which are TCs calling a bunch of related tests using callTestCase
.
i know. sometime i am inspiring from your approach when designing my projects ā¦ but not all the time
Sorry, I completely missed that youād mentioned test steps.
The only way to achieve that right now is to make your Test Cases look like this:
try {
reportMsg 'Stuff about step 1'
// Step 1 code
reportMsg 'Stuff about step 2'
// Step 2 code
// etc...
reportMsg 'Stuff about step N'
// Step N code
passThisTest()
} catch(Exception e) {
failThisTest(e.message)
}
You need to write your own reportMsg
, passThisTest
and failThisTest
methods - that is where you would be writing to your own report module. Here is my passThisTest
method:
/**
* A Test Case has completed successfully.
* The message is sent to the reports module.
* @param msg (String) The message.
*/
static void passThisTest(String msg = "This test passed!") {
comment("passThisTest")
def rep = new com.orgi.reports.Report()
new com.org.reports.Report().dispatchMessage(msg)
KeywordLogger log = new KeywordLogger()
log.logWarning(msg)
comment("passThisTest completed.")
}
@devalex88 has mentioned that the devs are working on a revamped reporting system based on a demo of my reporting system I gave to Alex some months ago. I donāt expect it to materialize very soon, but yes, itās on the horizon.
Sorry for late reply guys, I really appreciate the solution you provided. However, Iāve already achieved the same thing in non-plugin mode even for steps. I simply try to find a way to implement it in plugin mode
You should probably make your title more clear.
Yeah I just wanted to ask if there test cases and test steps hook in next releases or there is a way to achieve that . Again, Iām really appreciate for sharing your approaches.
To make things clear, my idea is to keep the test cases as simple as possible (without try catch or additional common functions to send requests), thus I implemented those logics in a separate listener to send request after each step (line) in scripts, even for the ones in hooks.