Hello all,
I find no other reference to org.junit.Parameterized in the code stack on trunk
which indicates that no-one else has committed parameterized unit tests. I am
asking because I have a test case where I would need that (I want to run all
options for the CustRequestStatusType against the status check service an be
sure it return the expected result) and when implementing I find that my IDE
hints that „There is no default constructor available in class
‚org.apache.ofbiz.service.testtools.OFBizTestCase‘“.
package org.apache.ofbiz.order
import org.apache.ofbiz.service.ServiceUtil
import org.apache.ofbiz.service.testtools.OFBizTestCase
import org.junit.Test
import org.junit.runner.RunWith
import org.junit.runners.Parameterized
import org.junit.runners.Parameterized.Parameters
@RunWith(Parameterized)
class CustRequestStatusTests extends OFBizTestCase {
private String status
private String expect
private String scenario
@Parameters static scenarios() {[
['CRQ_DRAFT', 'PASS', 'CustRequest status Draft expected to PASS'],
['CRQ_SUBMITTED', 'PASS', 'CustRequest status Submitted expected to
PASS'],
['CRQ_ACCEPTED', 'PASS', 'CustRequest status Accepted expected to
PASS'],
['CRQ_REVIEWED', 'PASS', 'CustRequest status Reviewed expected to
PASS'],
['CRQ_PENDING', 'PASS', 'CustRequest status Pending expected to
PASS'],
['CRQ_COMPLETED', 'FAIL', 'CustRequest status Completed expected to
FAIL'],
['CRQ_REJECTED', 'PASS', 'CustRequest status Rejected expected to
PASS'],
['CRQ_CANCELLED', 'FAIL', 'CustRequest status Cancelled expected to
FAIL'],
]*.toArray()}
public CustRequestStatusTests(String name, String status, String expect,
String scenario) {
this.expect = expect
this.scenario = scenario
this.status = status
super(name)
}
/* Testing custRequestStatusCheck Service Implementation
*
* available test data:
* (...)
* <CustRequest custRequestId="9000" custRequestDate="2008-07-28
09:45:31.928" custRequestTypeId="RF_QUOTE" statusId="CRQ_ACCEPTED"
fromPartyId="DemoCustomer" priority="9" custRequestName="Customer Request
Usage" description="Demo CustRequest" productStoreId="9000"/>
* <CustRequestItem custRequestId="9000" statusId="CRQ_ACCEPTED"
custRequestItemSeqId="00001" productId="GZ-1001" story="This can be the longer
story of an item on the customer request."/>
*
* */
@Test void testCustRequestStatusCheckEmpty() {
Map input = [
custRequestId: '9001',
]
Map result = dispatcher.runSync('checkStatusCustRequest', input)
assert ServiceUtil.isError(result)
// assert error message refers to certain text element
}
@Test void testCustRequestStatusCheckWrongStatus() {
Map input = [
custRequestId: '9000',
statusId: this.status,
]
Map result = dispatcher.runSync('checkStatusCustRequest', input)
if(this.expect == 'PASS') {
assert ServiceUtil.isSuccess(result)
} else {
assert ServiceUtil.isFailure(result)
}
}
}
This hint certainly has to do with the implementation I need to do for such
test cases using annotations to mark the class as @Parameterized, define the
@Parameters and then mark the @Test that uses the parameters.
Before I dive too much into web search:
- has anyone attempted this for OFBiz unit Testing? (And hence the reason why
no implementation is avail)
Thanks for a hint :)
Warm regards
Carsten