Use status severity and codes in JDT model test assertions#5008
Use status severity and codes in JDT model test assertions#5008fedejeanne wants to merge 2 commits into
Conversation
|
@trancexpress I think these kind of assertions would make the tests less brittle. In general, I try to write tests in a way that they do not check for (error) messages unless of course the sole purpose of the test is to validate the message. These tests are not interested in the message itself but in the kind of error produced by the operations. WDYT? |
|
From my POV its OK for these tests to check with the status error code instead of the message. |
|
In that case, if you decide to merge this one then #5005 may be dropped👍 |
Should we just merge #5005 ? |
|
#5005 got merged, do we continue here? |
|
@trancexpress I am at the OCX this week so I won't be able to look at it. I can continue this PR next week so please don't close it :-) |
67311cd to
fb59e04
Compare
fb59e04 to
fc36a26
Compare
|
I rebased on master and I also added a 2nd commit that removes unnecessary code (discovered by the checks in this PR) |
|
Still interested on this one, @trancexpress ? :-) |
I don't think So one more item from me: Can you check if |
You mean checking the text of the error message in the tests too like #5005 did? The purpose of this PR was the exact opposite: to not check the messages since the most important thing is the kind of generated error. Or did I misunderstood your comment? |
|
ping @trancexpress |
For me as a user, the error kind doesn't help much. I can imagine seeing the right error kind in the test, but the wrong message. If we can at least shift the responsibility somewhere, e.g. ask This can still backfire if |
I agree with that but the test is not about what the user sees (the message), it is about Did this error happen (yes/no)?. Which is why I propose to let the test pass/fail based on whether or not the error happens and let the message be merely what
IIUC you propose to do something like this (pseudo-code) String expectedMessage = JavaModelStatus.getMessage(IJavaModelStatusConstants.INCOMPATIBLE_JDK_LEVEL);
assertStatus(
"should have complained about jdk level mismatch",
expectedMessage,
status);right? In that case, the logic would be the same I have right now because one would get the protected void assertStatus(String message, int expectedSeverity, int expectedCode, IStatus status) {
assertStatus(message, expectedSeverity, status);
assertEquals(message, expectedCode, status.getCode());
}... or did I get you wrong? |
An alternative to #5005 .
Do the checks/assertions based on the status and the error code instead of the text.