TestProject Forum

TestProject Platform => TestProject SDK => Topic started by: Ybarakhtyan on August 03, 2018, 10:06:31 am

Title: How I can use addon proxy in test
Post by: Ybarakhtyan on August 03, 2018, 10:06:31 am
Hello,
I created and successfully uploaded addon. After that I download it by link and attach to project (via references).
And I cannot use it as is in your example - https://github.com/testproject-io/java-sdk-examples/tree/master/Web#crowd-code--addon-proxy

Please describe how I can use my addon in test.
My downloaded addon is here - https://drive.google.com/open?id=1rxGufcEMDxTiv2H5o0XJFidmR8trEOq8
Title: Re: How I can use addon proxy in test
Post by: Marat Strelets on August 03, 2018, 15:30:38 pm
Can you please upload your original Addon's JAR?
It seems that something is missing and the proxy JAR has no relevant code to proxy.
Title: Re: How I can use addon proxy in test
Post by: Ybarakhtyan on August 03, 2018, 15:41:06 pm
This is link to original file - https://drive.google.com/open?id=11mIUZViLHo2Q6JVquw1MNVnNw5smiaJS
Title: Re: How I can use addon proxy in test
Post by: Marat Strelets on August 03, 2018, 16:06:14 pm
We have identified the problem.
It is happening because your class "RandomDestination" has no package.

Until we fix the issue, please place your class "RandomDestination" in a package (e.g. 'mypkg')
Then please re-upload the addon and re-generate the proxy.

The proxy should have two classes inside -

You should use io.testproject.proxy.addon.RandomDestination.getRandomDestination() to obtain an instance of your Action's proxy.
Then you can pass this instance to the helper's executeProxy() method.

Hope this helps.
Title: Re: How I can use addon proxy in test
Post by: Ybarakhtyan on August 03, 2018, 16:27:06 pm
Thank you. All is ok now.
Title: Re: How I can use addon proxy in test
Post by: Ybarakhtyan on August 03, 2018, 21:42:43 pm
I added following code:
ActionProxy action = RandomDestination.getRandomDestination();
 helper.executeProxy(action);


When I execute test I see following error on  helper.executeProxy(action) line

ERROR io.testproject.java.sdk.v2.Runner - Failed to execute codeblock class com.testpoject.ievgen.tests.BasicTest
java.lang.NullPointerException: null
   at io.testproject.java.sdk.v2.tests.helpers.TestHelperEx.extractProxyResults(TestHelperEx.java:70) ~[io.testproject.sdk.java.jar:na]
   at io.testproject.java.sdk.v2.tests.helpers.TestHelperEx.executeProxy(TestHelperEx.java:51) ~[io.testproject.sdk.java.jar:na]
   at com.testpoject.ievgen.tests.BasicTest.execute(BasicTest.java:32) ~[bin/:na]
   at io.testproject.java.sdk.v2.Runner.execute(Runner.java:195) [io.testproject.sdk.java.jar:na]
   at io.testproject.java.sdk.v2.Runner.run(Runner.java:420) [io.testproject.sdk.java.jar:na]
   at io.testproject.java.sdk.v2.Runner.run(Runner.java:386) [io.testproject.sdk.java.jar:na]
   at io.testpoject.proxy.addon.RandomDestination.TestRunnerTest.main(TestRunnerTest.java:21) [bin/:na]


My original addon here - https://drive.google.com/open?id=11mIUZViLHo2Q6JVquw1MNVnNw5smiaJS
Title: Re: How I can use addon proxy in test
Post by: KarenTeb on August 04, 2018, 18:58:57 pm
Hi,

We fixed a bug, so can you please download the new SDK?
Let us know if it works well for you after that.

Thanks!
Title: Re: How I can use addon proxy in test
Post by: Ybarakhtyan on August 04, 2018, 23:05:39 pm
I downloaded new version of SDK. And tried execute test with it.  The same error.
My test project in JAR file is here - https://drive.google.com/open?id=1-mZdojhMplJZkT0q1S3WKBWclIuKAx85

Do I need also add sdk to addon project and recreate jar file of add-on?
Title: Re: How I can use addon proxy in test
Post by: Marat Strelets on August 05, 2018, 16:16:34 pm
All of your code references to the SDK should be updated.
In a nutshell, this is happening because your original add-on code throws an exception.
Before trying to execute it in a Test via proxy, I would suggest making sure it works in a stand-alone mode, via Runner and via TestProject Recorder.
Title: Re: How I can use addon proxy in test
Post by: Marat Strelets on August 07, 2018, 17:05:15 pm
Locked due to inactivity.