BDD Testing: Step definition files is not able to recognize the custom keywords from plugin

Hi,

I have one plugin for custom keywords which I’am trying to use in Step definition file.
I have tried following ways:

  1. Using like normal custom keyword in groovy file :
    CustomKeywords.‘keywords.Package.method()’

  2. Importing the package and using the function by creating class of the package as mentioned here ‘BDD Testing: Step Definition files doesn't recognise Customkeywords’:

import keywords.Package

and in step def using like this:
new Package().method()

  1. By creating a new custom keyword and using the plugin there like:
    import the package: import keywords.Package
    and create a custom keyword like this:

@Keyword
def abc(){
new Package().method()
}

but none of the above ways worked for me. Also, did not throw any error. In case I use invalid keyword name which is not available in plugin then it throws error like no signature found or something.But when providing correctly, it is not working either.

Basically i want to use keyword from the plugin in the step definition file. Is it possible?

Infact I’m unable to use custom keywords from the same project (not from plugin) in step definition file.

Sorry, I do not see how your codes look like.

Please use “Code Formating feature” to present codes easyer to read.

And please show us your

  • codes under the “Keywords” folder
  • codes under the “Include” folder
  • codes under the “Test Cases” folder
    with exlicit file names.

And please show us any error messages from Katalon Studio. Screenshots would be nice.

This is the keyword in my plugin that I’m trying to use:

And this is how Im using in BDD framework:

And Im not getting any error from katalon, just that it is not logging what is mentioned inside the description.

Okay…now I realized that it is working but not logging this in JUnit Report.xml:

2020-02-27 13:52:00 - [TEST_STEP][PASSED] - ert.reporter.Tests.startStep(“I login to the application”):I login to the application

and we are basically using this log from the JUnit report in some other functionality.

Then, your question is restated now: how to log a message “I login to the application” in JUnitReport.xml? right?

I suppose that you can find a line of

2020-02-27 13:52:00 - [TEST_STEP][PASSED] - ert.reporter.Tests.startStep(“I login to the application”):I login to the application

in a <system-out> element of JUnitReport.xml. Could you have a look at your JUnitReport.xml?

Or, do you have any specific idea how the message should be presented in JUnitReport.xml? Then please describe it.

No, this is not getting logged in JUnitReport.xml. May be because it is not treated like a normal keyword? I don’t know.

And you’re right, I was expecting exactly such line in JunitReport.xml.

Let me tell you what I just guess. I am not sure. I haven’t examined at all…

In the ert.reporter.Tests class, you have this:

    @Keyword
    def startStep(String stepDescription) {
        KeywordUtil.markPassed(stepDescription)
    }

Please try changing as follows:

    @Keyword
    def startStep(String stepDescription) {
        println stepDescription
    }

Then, you will find the message in the JUnitResult.xml.


The <system-out> section of JUnitReport.xml will print the output emitted into System.out by the tests. println stepDescription will emit the string into System.out.

But KeywordUtl.markPassed(String message) will NOT output message into the System.out. It will print message just in the LogView of Katalon Studio.

You can check the source code of KeywordUtil#markPassed() here:

As long as you call KeywordUtil.markPassed(...) statement, I think, you will not find the message in JUnitReport.xml. If you want to see the message in JUnitReport.xml, use println instead of KeywordUtil.

Or, you can call both of println message and KeywordUtil.markPassed(message) if you like.

Actually this is getting logged as a message like [Message][Passed], I wanted it to be logged as a step, like [Test_Step][Passed], but I guess that is not possible here.
I wanted to check whether that keyword has been executed or not and for that im relying on a Test Step with log as ert.recorder.Tests.startStep.

No issues, Ill try to make changes in my other utility.