How to Test custom validation with JUnit [message #1806991] |
Mon, 20 May 2019 14:13  |
Eclipse User |
|
|
|
Hi,
I try to test my validation with JUnit.
class MyDslValidator extends AbstractMyDslValidator {
@Check
def checkPosition(CANSignal can){
if(can.pos < 0 || can.pos > 100){
warning("Position out of Range", MyDslPackage.Literals.CAN_SIGNAL__NAME)
}
}
}
This works so far in the Editor. When I edit a greater Value i get the message, Now I want to make a JUnit test for it and fail. I read some but don't find the correct solution. Eclipse says
org.junit.ComparisonFailure: expected:<E[rror : Position]> but was:<E[xpected WARNING 'Position out of Range' on CANSignal at [-1:-1] but got
WARNING (null) 'Position out of Range' on CANSignal, offset 62, length 8
My TestCode (not complete)
@Test
def void validationTest(){
'''
Position 500
'''.parse.assertPosition("Position")
}
def void assertPosition(Domainmodel domainmodel, String string){
domainmodel.assertWarning(MyDslPackage.eINSTANCE.CANSignal, "Position out of Range" ,"Error : " + string )
}
I read in the book of Bettini but don't get it.
How to test it properly? Valid Positions, greater and smaller than the range?
Thanks
Markus
|
|
|
|
|
|
Powered by
FUDForum. Page generated in 0.04771 seconds