TestProject Forum
Powered by leading experts in the test automation community

Why is it so difficult to write addons?

Hello!
I ran into difficulties writing new add-ons for testproject.
Example: We need a plugin that will connect to redis and take the key value from there. I need one dependency - some redis client (I took reddison) and a couple of lines of code.
Next, I write a test for the created action, which is launched through the runner. Everything seems to work and everything is fine!
Until I start loading this into testproject …
The first thing I encountered was a dependency conflict. (A large number of warning NoClassDefFoundError). The solution I eventually came up with was to build uber-jar using the maven-shade-plugin, moving the packages of your dependencies to another place. This more or less solved the problem, but it requires unnecessary actions (register specific packages in the shade plugin - relocation section). With the assembly you propose through gradle or maven-assembly-plugin it is almost impossible to connect libraries normally, which is very frustrating. Perhaps the pom-file with the dependencies used in the testproject runner (I’m not sure) would help, in order to somehow inherit from it cunningly.
The second problem is not clear error messages.
Example: I loaded my plugin to testproject to connect to redis, but I get an error when using:

java.util.concurrent.ExecutionException: java.security.AccessControlException: access denied (“java.lang.RuntimePermission” “reflectionFactoryAccess”)
Caused by java.security.AccessControlException: access denied (“java.lang.RuntimePermission” “reflectionFactoryAccess”)

Or another example, this is in the plugin for performing actions in ldap:

java.util.concurrent.ExecutionException: java.lang.ExceptionInInitializerError
Caused by java.lang.ExceptionInInitializerError

At the same time, everything works in the developer session in tests, so I don’t understand how I can catch these errors in advance and why they arise (in the first case, as I understand it, the plug-in does not have enough rights for some action), and most importantly - where they arise. There is nothing in runner logs either.

Sorry for the bad english. I really like your product, now all testers write autotests on their own, but writing plugins is frustrating. When writing code takes 20 minutes, and then another half day to get it to work correctly. I would be glad if there is an easier way to connect third-party libraries and fully check the addon for errors without loading it into testproject

1 Like

Hello @tihonina
Currently our SDKs are being re-hauled, all reports can be directly reported from your IDE without the need to upload them as Coded Tests.

Also, it seems you are using Maven as your build tool, you need to use the descriptor.xml when you use Maven with our SDK as it takes all the plugins and 3rd party libraries you linked into your Jar and creates the jar-with-dependencies which is the one you need to upload.

Here is a link for an example of the desciptor.xml: https://github.com/testproject-io/java-sdk-examples/blob/master/Web/Addon/src/main/descriptor.xml

Next time you use Maven, create this descriptor.xml before compiling your project.

Best Regards, Ran.

@ran.tzur Hi, I a have been facing the same issue (java.util.concurrent.ExecutionException: java.lang.ExceptionInInitializerError
Caused by java.lang.ExceptionInInitializerError at java.base/java.util.concurrent.FutureTask.report(FutureTask.java:122)) with Add On development and just like @tihonina i am able to execute successfully with the developer session in tests, the problem arises only when the add on is uploaded and imported in the test. Also if I upload the same solution as a Test in TestProject instead on AddOn , it works.

my project is gradle and I am using the descriptor.xml but the issue is not resolved. Please do the needful.

Thanks,
Aravind

Hello @arawin.aravindhan
Addons run on a sandboxed environment, meaning not all operations can work unless they are given access by the manifest.json file while creating the addon.
If your addon uses stuff like network, environment, file system and so on make sure you ticked those while generating the manifest file.
Note: This is the reason why it worked as a Test and not as an Addon.