How to use the Test Listeners from the plugins

Hi,

I have generated one plugin and it also has some Test Listeners. If I use this plugin in any other project, the Test Listeners are not working as expected.
Is there any other way of using the listeners from the plugin or it will work just automatically with the plugin?

Another question is if it should work, then what will happen if there are same methods say ‘beforeTestCase’ inside Test Listeners of plugin and also in the Test Listeners of the project where this plugin is copied? Which one will be considered?

I do not think it is possible.

Let me assume you hava a jar file of your custom classes.

Your test case scripts can call your custom classes from the jar files located either of the “Driver” directory or the “Plugins” directory. In this case, your custom classes are known as “Keywords”.

Katalon Studio’s test execution engine loads the classes as TestListener only from a specific directory named “TestListerner”. The engine never loads classes as “TestListener” from your “plugin” jar.

All you can do is to write a short groovy script in the TestListener direcotry, and the script calls your classes as TestListener contained in your custom jar file. You can see an example:

Okay, I thought this is possible.
I read this section ’ Package Test Listeners as plugins’ from this link ‘Katalon Studio 6.1.1 Beta’.

Im asking this because there are few plugins in katalon store which has Test Listeners, so that means to use that plugins we need to copy those Test Listeners explicitly in our projects to make it work?

I am afraid, I do not understand your question.

Let me ask you a question. In the “TestListerner” directory, you can locate 2 or more “TestListener” scritpts. All of them will be executed by Katalon Studio. Are you aware of that?

Say you have 2 TestListerns: TL1 and TS2. TL1 has @beforeTestCase method, and TL2 also has @beforeTestCase method. Fine. Both will be executed by KatalonStudio. Order? I do not know. TL1 may be first, or TL2 may be first — I think you should make your code independent of the order.

Ah, I did not know that. Sorry, I was wrong.

No problem @kazurayam
Lets wait for someone from Katalon Team may be to reply.

@devalex88
@Russ_Thomas
@duyluong
@Marek_Melocik

Could you please help here?

Okay, I thought this is possible.
I read this section ’ Package Test Listeners as plugins’ from this link ‘Katalon Studio 6.1.1 Beta ’.
Im asking this because there are few plugins in katalon store which has Test Listeners, so that means to use that plugins we need to copy those Test Listeners explicitly in our projects to make it work?

When building a custom keyword plugin, the Test Listeners should embed into the plugin jar.

Copy the created plugin in to Plugins folder and open the project, Katalon will search for plugins in this folder (if your account is KSE).

You don’t need to call or copy the Test Listener of the custom keyword plugin. Katalon Engine will call the Test Listeners of the plugin when running.

Please refer to our Basic Report Plugin as an example: https://github.com/katalon-studio/katalon-studio-basic-report-plugin

@duyluong

I have a question.

If my plugin jar contains multiple classes with @beforeTestCase annotated methods, then Katalon Studio calls ALL of them? How can I nominate only one of them in a project to be called by Katalon Studio?

@kazurayam

If my plugin jar contains multiple classes with @beforeTestCase annotated methods, then Katalon Studio calls ALL of them

Yes. Katalon Studio will call them all.

How can I nominate only one of them in a project to be called by Katalon Studio?

Currently, Katalon Studio doesn’t provide this feature. Can you share some ideas about the benefit for users if KS introduces this feature?

I am no serious about this issue at all. I just asked it for clarification.

I would just request Katalon Team to write that all multiple TestListeners in a plugin jar will be called by KS.

I will transfer this request to the document team. Thanks for your suggestion.

I realised why it was not working in my case. The default class of the listener is Test Listener and same class was available in plugin as well as in the project where the plugin was being used.
That was causing conflict may be.
Works now.

Thank you. :slight_smile: