-
Notifications
You must be signed in to change notification settings - Fork 616
OFBIZ-13311 Improved: Rewrite UtilCacheTest #916
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: trunk
Are you sure you want to change the base?
Conversation
(OFBIZ-13311) Rewrites the test class UtilCacheTest. Changes the variable names to make them more clear and moves the test utility objects to a dedicated new class. Also removes the GenericTestCaseBase, that was used only in the UtilCacheTest. Deleted a part of the testExpire test method, that was based on the useAllMemory method, which is highly OS or hardware dependant making unit test dependant as well. Thanks: Nicolas for the help in analyzing.
6cff1d8 to
2caa71f
Compare
Removes the Serializable interface from the test declaration. Still successes, and there doesn't seems to be any advantage to it.
Removes the exception from test signature and fails the test in case of Exception.
Plus moved java tests to allow groovy ones.
|
Feedback on what was done in the task, and while re-writing
|
|
Hi Gaetan, I do have one concern about useJUnit(), which, if I’m not mistaken, configures Gradle to use JUnit 4. I believe there are some Groovy tests that rely on JUnit 5, so this change might prevent them from running. More generally, it would be helpful to better understand the underlying reasons for the issues we encountered, as this knowledge could help us improve our testing framework setup. Anyway, thanks for your work! In my opinion, we can accept this pull request if you feel confident about it. |
|
|
Thanks for the feedback. Indeed, some of the test that are specified in the build.gradle file are not run anymore with junit enabled explicitely. |
|
After some resarch, here is my analysis. include 'org/apache/ofbiz/service/ModelServiceTest.groovy'
include 'org/apache/ofbiz/test/TestServices.groovy'
include 'org/apache/ofbiz/base/util/string/FlexibleStringExpanderBaseCodeTests.groovy'
include 'org/apache/ofbiz/base/util/FileUtilTests.groovy'
include 'org/apache/ofbiz/service/test/ServicePurgeTest.groovy'
include 'org.apache.ofbiz.base.test.SimpleTests.groovy'ModelServiceTest.groovy, FlexibleStringExpanderBaseCodeTests.groovy, and FileUtilTests.groovy are indeed unit tests, and already are in relevant test sources. With junit enabled in build.gradle, they run and don't need the explicit declaration. TestServices.groovy is a groovy service file, and doesn't contain any test. It was most likely added by mistake. As for ServicePurgeTest.groovy and SimpleTests.groovy, they look like integration tests. I suggest reenableing these tests in appropriate components (commented for now until they are validated) and keeping the simple junit architecture. By the way, @JacquesLeRoux , do you remember the reason behind this commit that removed the test declaration ? I'm not sure I understand why ServicePurgeTest.groovy and SimpleTests.groovy wouldn't be integration tests anymore |
|
ModelServiceTest.groovy should depend on Junit 5 too |
|
@jacopoc do you mean the test class should be an integration test ? Because it uses a dispatcher ? |
|
Hi Gaetan, Jacopo, First, thanks Gaetan for your effort in this matter (tests), not so complex but sometimes kind of complicated. Thanks too Jacopo for your help. When we worked on https://issues.apache.org/jira/browse/OFBIZ-12813, which was a massive task among related others (Minilang services and tests migration to Groovy, notably https://issues.apache.org/jira/browse/OFBIZ-12995), we missed some points. Great this part (tests) was reviewed. About TestServices.groovy I'm torn after having a look and trying things. Also I already had a look at your question and stumbled upon issues. I'll get back to those points later... |
Actually, it seems to me that as soon as dispatcher or delegator is used the test should be considered an integration one, even if there is no real access to the DB (but then why using them ?). BTW, I wonder if ModelServiceTest.groovy should not extend GroovyScriptAssert.java. Maybe indeed the Mockito cas is particular. |
|
Hi Jacques !
I agree with this.
I also agree, and i think it is the indented use of the GroovyScriptAssert.java class. To allow easy integration tests to be written. So this would give the following next actions / tasks :
|
|
@gtchaboussie I am referring to the fact that ModelServiceTest imports the org.junit.jupiter.api.* that was introduced with JUnit 5. |
|
Sorry guys, I did nothing after my message. I got a very weird "computer" issue today. Suddenly, "while doing nothing", the screen (a Of course in the middle of all that, I did some other things. It's quite stressing when you loose your screen! |
|
Hi Gaetan,
I tried to us SimpleTests.groovy as it was, a JUNIT simple test. It turned out to be impossible because of dispatcher that ultimately needs dispatcherFactory which is only assigned in ServiceContainer::init. Else SimpleTests::testTrue and SimpleTests::testDelegator worked. So I converted SimpleTests.groovy to be an integration test. I have slightly modified the comments about that in build.gradle and will do the same in developer-manual.adoc where the OFBiz components main directory structure is documented. I continue on the rest... |
|
All tests in ModelServiceTest.groovy are OK as is (unit-tests). About ServicePurgeTest.groovy, it's now an integration test as it should always have been. TestServices.groovy is not a real test and should not have been considered as. As I said the services and tests migration from Minilang to Groovy was a huge task; not surprised that few wrong cases escaped to us. Here is attached OFBIZ-13311.patch which concludes my work. I'll also post it on the related Jira. I guess it's better to apply it after the rest on your side has been completed, just pick what you prefer to do :) |
|
Hi Gaetan, Mmm, something I forgot I not only changed TestServices.groovy but also moved it. So maybe testing it and even more committing it could be a problem with a simple patch. I suggest rather that I wait for your work here to be completed and then I'll push directly from my side, OK? |
|
That's ok for me. I'll just push the CacheTest rewrite then, and let you contribute the other tests fixes. |
|
👍 |
|
The tests don't run anymore. Investigating.. |



(OFBIZ-13311)
Improved: Rewrites the test class UtilCacheTest.
Changes the variable names to make them more clear and moves the test utility objects to a dedicated new class.
Also removes the GenericTestCaseBase, that was used only in the UtilCacheTest.
Deleted a part of the testExpire test method, that was based on the useAllMemory method, which is highly OS or hardware dependant making unit test dependant as well.
Thanks: Nicolas for the help in analyzing.