Hello all,
Me again. I forgot to mention here that actually now I do execute the Unit Tests, but also three integration test classes are executed as part of the JUnit run. All three are extensions to org.apache.ofbiz.service.testtools.OFBizTestCase and to not define any Unit @Test annotation on the class methods. Yet they are recognized and executed … and fail of course since the data load has not occurred. Any advice you might have is much appreciated. Warm regards Carsten > Am 10.09.2024 um 10:36 schrieb Carsten Schinzer > <cars...@dcs-verkaufssysteme.de>: > > Hello all, > > > Thanks to the help of Gaetan, we have been Abel to spot the issue: > > > I had attempted to install and run JUnit5 testing in my component only > > which obviously does not work as JUnit5 Test annotation would not be > > recognized by the Gradle build tool. > > Therefore, in order to resolve this, I had to rework all Unit tests to comply > with JUnit4 which - since I had quite a number of parameterized tests - was > quite an effort. > > In order to move on to more recent test concepts, namely parameterized > testing but also improved test architecture with a better separation of > asserts into a package instead of a class which enables custom asserts I have > logged a relate feature request here: > https://issues.apache.org/jira/browse/OFBIZ-13138. > I am happy to contribute to this myself, yet with this issue I have also > learned that I do not fully understand the gradle build setup for OfBiz and > would need quite some guidance. > > So if anyone would like to pull on this with me - please let me know! > > Thanks again to Gaetan, this current project is now moving forward again! > > Warm regards > > > Carsten > > >> Am 21.06.2024 um 11:17 schrieb Carsten Schinzer >> <cars...@dcs-verkaufssysteme.de>: >> >> Hi Gaetan, >> >> Thanks to get back to me. I see no change - all the things you applied I >> already did. >> I also added your test case to the code and ran that locally - the test is >> obviously not found. >> >> It might have to do with the fact that I prefer JUnit 5 because of its >> advanced parametrized testing features? >> I can give you access to the code repo if you have a Gitlab account. >> >> When running tests locally, I do not see any test reports for my classes, so >> this is the indicator I am using. >> Also, I have test cases that should fail with the current code state. >> >> So situation is unchanged unfortunately. >> Warm regards >> >> >> Carsten >> >>> Am 20.06.2024 um 16:58 schrieb Gaetan <gaetan.chabous...@nereide.fr>: >>> >>> Hi Carsten, do you have any updates on your case ? >>> >>> Regards, >>> >>> Gaetan >>> >>> On 6/11/24 09:58, Gaetan wrote: >>>> Hello Carsten. >>>> >>>> I set up a very small example plugin that i tested myself localy. Could >>>> you please reproduce the steps below ? >>>> >>>> - get ofbiz framework from apache repo >>>> (https://github.com/apache/ofbiz-framework) >>>> >>>> - checkout trunk on ofbiz framework >>>> >>>> - get example plugin and set it up inside plugins >>>> (https://github.com/gtchaboussie/ofbiz-demo-test-plugin) >>>> >>>> at the ofbiz root location, run `./gradlew test`. The build should fail >>>> (this means the test in the plugin is runned) with this error: >>>> >>>> ``` >>>> >>>> org.test.TestClass > test FAILED >>>> java.lang.AssertionError at TestClass.java:9 >>>> >>>> ``` >>>> >>>> This gives you a template or example of a unit test. >>>> >>>> As you can see, you should not have to update anything on the base >>>> framework for your tests yo be runned. >>>> >>>> Also, could you share your OS and OFBiz version ? >>>> >>>> Regards, >>>> >>>> Gaetan >>>> >>>> On 6/10/24 19:13, Carsten Schinzer wrote: >>>>> Hello Gaetan, >>>>> >>>>> >>>>> I do all this as you describe, source path for tests is as required and >>>>> tests are properly annotated. >>>>> The main difference is that this is not a unit test out of a framework, >>>>> but >>>>> unit tests sitting in a plugin component. >>>>> >>>>> I so not see any traces of the framework stepping into my test directories >>>>> when executing test (I ran .gradlew test —info to get more info). >>>>> >>>>> IMO something is probably missing in my build.gradle: >>>>> >>>>> /*…*/ >>>>> >>>>> dependencies { >>>>> // information: the ofbiz:release22.01 is on >>>>> jakarta.ws.rs:jakarta.ws.rs-api:2.1.6 >>>>> pluginLibsCompile 'org.glassfish.jersey.inject:jersey-hk2:2.31' >>>>> pluginLibsCompile >>>>> 'org.glassfish.jersey.containers:jersey-container-servlet:2.31' >>>>> pluginLibsCompile >>>>> 'org.glassfish.jersey.media:jersey-media-json-jackson:2.31' >>>>> pluginLibsCompile 'javax.json:javax.json-api:1.1.4' >>>>> pluginLibsCompile 'jakarta.inject:jakarta.inject-api:2.0.1' >>>>> pluginLibsCompile 'jakarta.ws.rs:jakarta.ws.rs-api:2.1.6' >>>>> pluginLibsCompile >>>>> 'com.fasterxml.jackson.core:jackson-annotations:2.16.1' >>>>> pluginLibsCompile 'com.fasterxml.jackson.core:jackson-core:2.16.1' >>>>> pluginLibsCompile 'com.fasterxml.jackson.core:jackson-databind:2.16.1' >>>>> pluginLibsCompile >>>>> 'com.fasterxml.jackson.datatype:jackson-datatype-jsr310:2.16.1' >>>>> // Swagger Annotations for OpenAPI >>>>> pluginLibsCompile 'io.swagger.core.v3:swagger-annotations:2.2.20' >>>>> // Swagger JAX-RS Integration for OpenAPI >>>>> pluginLibsCompile 'io.swagger.core.v3:swagger-jaxrs2:2.2.20' >>>>> // Swagger UI >>>>> pluginLibsCompile 'org.webjars:swagger-ui:4.1.3' >>>>> // Junit core, api and parameterization >>>>> pluginLibsCompile 'org.junit.jupiter:junit-jupiter:5.10.0' >>>>> pluginLibsCompile 'org.junit.jupiter:junit-jupiter-api:5.10.0' >>>>> pluginLibsCompile 'org.junit.jupiter:junit-jupiter-params:5.10.0' >>>>> } >>>>> >>>>> task install { >>>>> doLast { >>>>> // Install logic for this plugin >>>>> } >>>>> } >>>>> >>>>> task uninstall { >>>>> doLast { >>>>> // uninstall logic for this plugin >>>>> } >>>>> } >>>>> >>>>> >>>>> I have dependencies on JUnit 5 since I want to use the ParameterizedTest >>>>> feature available there. Maybe that is the issue. I also cannot find a >>>>> passing build when stating these dependencies as pluginCompileOnly either. >>>>> >>>>> So almost certainly this is rather a hook into the test executionon grade >>>>> side, WDYT? >>>>> >>>>> Thanks for your comments so far! >>>>> Warm regards >>>>> >>>>> >>>>> Carsten >>>>> >>>>> >>>>> Am 10.06.2024 um 17:54 schrieb Gaetan <gaetan.chabous...@nereide.fr>: >>>>> >>>>> Hi again, >>>>> >>>>> After some research, it seems you should follow this kind of structure for >>>>> your unit tests : >>>>> >>>>> https://github.com/apache/ofbiz-framework/blob/7c2487bc3f1a6ec472585c27d7ceb5ca19471387/build.gradle#L259 >>>>> >>>>> >>>>> So you should setup your tests at the right package (either groovy or java >>>>> according to build instructions) and add the test decorator like this >>>>> example >>>>> >>>>> https://github.com/apache/ofbiz-framework/blob/7c2487bc3f1a6ec472585c27d7ceb5ca19471387/framework/base/src/test/java/org/apache/ofbiz/base/container/ComponentContainerTest.java#L63 >>>>> >>>>> >>>>> Please let me know if you encounter any more trouble ! >>>>> >>>>> Regards >>>>> >>>>> Gaetan >>>>> >>>>> On 6/10/24 16:55, Carsten Schinzer wrote: >>>>> >>>>> … and after some more assertions, I can add: >>>>> I have verified the paths to all my test suites to point to the correct >>>>> Java classes. >>>>> I do not find any error in the test logs. >>>>> I do find the classes in the build/classes/java/test directory. >>>>> I do not find related test results at all. >>>>> >>>>> An hint you can give me is appreciated! >>>>> Warm regards >>>>> >>>>> >>>>> Carsten >>>>> >>>>> Am 10.06.2024 um 15:47 schrieb Carsten Schinzer < >>>>> cars...@dcs-verkaufssysteme.de>: >>>>> >>>>> Hello, >>>>> >>>>> >>>>> You mean like this: >>>>> >>>>> <test-suite loader="main" location="testdef/CdcTicketsTests.xml“/ >>>>> Yes, I think I did it well like that. no? >>>>> Warm regards >>>>> >>>>> >>>>> Carsten >>>>> >>>>> >>>>> >>>>> Am 10.06.2024 um 09:17 schrieb Gaetan <gaetan.chabous...@nereide.fr>: >>>>> >>>>> Hi Carsten, did you include your tests in the ofbiz-component file a the >>>>> root of your plugin ? >>>>> >>>>> Best regards >>>>> >>>>> Gaetan >>>>> >>>>> On 6/9/24 21:15, Carsten Schinzer wrote: >>>>> >>>>> Hello all, >>>>> >>>>> >>>>> I am looking for a reference to integrate my plugin unit tests into the >>>>> test run of OfBiz, i.e. when I run >>>>> >>>>> ./gradlew test >>>>> >>>>> My defined test suite should be included and executed. >>>>> >>>>> I did browse the official plugin repository and found no reference. >>>>> >>>>> First issue: how to define the hook into the test task in build.gradle. >>>>> Second: Ho to make sure, the build.gradle dependencies on JUnit are only >>>>> loaded for test and not packaged. >>>>> >>>>> Does anyone have an example possibly how to do this. >>>>> >>>>> Thanks & warm regards >>>>> >>>>> >>>>> Carsten >>>>> >> >