#Unit test for Interceptor in wso2 Microgateway 3.2.0 and ballerina 1.2.13

1 messages · Page 1 of 1 (latest)

tawny flume
#

Hi there! I'am trying to perform unit test to my interceptors made in ballerina 1.2.13

When I use micro-gw build <GATEWAY_DIR> command the log prints this:
`vikcode@b:~/Documents/Gateways$ micro-gw build internal-financing-composition-gateway/
JAVA_HOME: /home/vikcode/Library/wso2/wso2am-micro-gw-toolkit-linux-3.2.0/lib/jdk8u202-b08-jre
Generating sources...[DONE]
Compiling source
wso2/internal-financing-composition-gateway:3.2.0

Creating balos
target/balo/internal-financing-composition-gateway-2020r1-java8-3.2.0.balo

Running Tests
ballerina: Oh no, something really went wrong. Bad. Sad.

There should be a file named "ballerina-internal.log" in the current directory.
If you are able to share with us the code that broke Ballerina then
we would REALLY appreciate if you would report this to us:
go to https://github.com/ballerina-platform/ballerina-lang/issues and
create a bug report with both this log file and the sample code...`

In ballerina-internal.log I found this:

[2023-09-26 11:11:44,700] SEVERE {b7a.log.crash} - null java.lang.NullPointerException at org.ballerinalang.packerina.task.RunTestsTask.createTestJson(RunTestsTask.java:242) at org.ballerinalang.packerina.task.RunTestsTask.execute(RunTestsTask.java:161) at org.ballerinalang.packerina.TaskExecutor.executeTasks(TaskExecutor.java:38) at org.ballerinalang.packerina.cmd.BuildCommand.execute(BuildCommand.java:427) at java.util.Optional.ifPresent(Optional.java:159) at org.ballerinalang.tool.Main.main(Main.java:57)

I know that the correct file system structure on ballerina to do some unit tests is only in modules:
my_module my_module.bal tests my_module_test.bal main.bal

but in wso2 microgateway not works that same way and there aren't any documentation to do test on microgateway, PLEASE some one help me if it it's is possible ? and how do it? Which is the correct file system structure to do unit test to interceptors ballerina.

still marsh
#

Can you check if this issue exists when the same scenario is executed via bal run?

tawny flume
#

Hi Thanks a lot for respond!, I tried same configuration on a ballerina project with same version and it works how is expected it. using bal build command.

tawny flume
#

@still marsh Hi, Do you have any clues or some or some path that you can follow, or is it simply not viable?

still marsh
#

Can you share the code that causes this issue?

tawny flume
#

@still marsh I share you generated files by wso2 microgateway in additional I've created a test directory within test bal file

#

I tried the command bal build internal and the result was:

#

The out was:

#

C:\Users\Bankaya7908\Documents\Ballerina\gen>bal build -a
Compiling source
wso2/internal:3.2.0

Creating balos
target\balo\internal-2020r1-java8-3.2.0.balo

Running Tests
wso2/internal:3.2.0
error: java.lang.NullPointerException
error: there are test failures

still marsh
#

Let us check and get back to you.