I've been fighting a bit with a class that has a boolean member. The matter is, from the web interface everything works as expected, however junit has its opinion on booleans that makes it fail.
In short, if I search manually a record I can leave the checkbox unset and it will find records with the checkbox set, assuming an empty checkbox is a neutral value.
Junit assumes that null equals false, and therefore will not find records with the member set to true. I don't object the behaviour of junit, however the difference between user experience and junit test cases can be a problem.
I don't even know if this is openxava specific or not, so maybe this isn't the right place to report. Or maybe I'm just doing it the wrong way.
Regards
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Thank you, however the key problem here is the difference in behaviour.
If I navigate the app with a browser, uncheck the boolean and hit search, I find both checked and unchecked records.
If I use junit and uncheck the boolean, it won't find checked records, just the unchecked ones. Therefore the behaviour differs. Technically the junit behaviour seems more correct. Since junit is supposed to act exactly like a user browsing the webapp this is at least misleading.
Is this a bug?
As I previously said I don't have much experience, so this may be nonsense.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
I think I know the root of your problem.
When you are using the webapp if you uncheck the boolean, it think that it is an empty field, so it is not included in the query condition.
When you are using junit, because you put 'false' to the property, this value is in the parameter list, so it's included in the query condition.
Try this case using OpenXava 3.0.3. This new version uses HtmlUnit instead of HttpUnit for junit, and the behaviour of the tests is more near to a real browser. Try it, and tell me the result.
Cheers
Javi
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
> Unfortunately 3.0.3 does not solve the problem
You can wait until 3.1 and try with it. If you case still fails, then you can consider to fix the problem yourself and contribute the fix to OpenXava ;)
Cheers
Javi
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
I've been fighting a bit with a class that has a boolean member. The matter is, from the web interface everything works as expected, however junit has its opinion on booleans that makes it fail.
In short, if I search manually a record I can leave the checkbox unset and it will find records with the checkbox set, assuming an empty checkbox is a neutral value.
Junit assumes that null equals false, and therefore will not find records with the member set to true. I don't object the behaviour of junit, however the difference between user experience and junit test cases can be a problem.
I don't even know if this is openxava specific or not, so maybe this isn't the right place to report. Or maybe I'm just doing it the wrong way.
Regards
Hi Enigma,
in order to assign value to a checkbox in detail model just type:
setValue("paid", "true"); // To check
setValue("paid", "false"); // To uncheck
And for filtering in list mode:
setConditionValues(
new String [] { "", "", "", "true" }
);
You can find more examples in OpenXavaTest/test-src
Cheers
Javi
Thank you, however the key problem here is the difference in behaviour.
If I navigate the app with a browser, uncheck the boolean and hit search, I find both checked and unchecked records.
If I use junit and uncheck the boolean, it won't find checked records, just the unchecked ones. Therefore the behaviour differs. Technically the junit behaviour seems more correct. Since junit is supposed to act exactly like a user browsing the webapp this is at least misleading.
Is this a bug?
As I previously said I don't have much experience, so this may be nonsense.
Hi Enigma,
I think I know the root of your problem.
When you are using the webapp if you uncheck the boolean, it think that it is an empty field, so it is not included in the query condition.
When you are using junit, because you put 'false' to the property, this value is in the parameter list, so it's included in the query condition.
Try this case using OpenXava 3.0.3. This new version uses HtmlUnit instead of HttpUnit for junit, and the behaviour of the tests is more near to a real browser. Try it, and tell me the result.
Cheers
Javi
Unfortunately 3.0.3 does not solve the problem, at least there's an easy workaround once the problem is acknowledged.
Regards
Hi Enigma,
> Unfortunately 3.0.3 does not solve the problem
You can wait until 3.1 and try with it. If you case still fails, then you can consider to fix the problem yourself and contribute the fix to OpenXava ;)
Cheers
Javi