I have written following Fixture and FitnessTest for that fixture, but somehow FitNesse is not able to find the Fixture. I simply provide username and password (blank intentionally), and then check for languagecode, countrycode, and variantcode for that user:
public class UserLanguageFixture extends TestSetup {
private String userId;
private String password;
private String languageCode, countryCode,
variantCode;
UserLanguageFixture(String userId, String password) {
this.userId = userId;
this.password = password;
}
UserLanguageFixture() {
}
public void setUserId(String userId) {
this.userId = userId;
}
public void setPassword(String password) {
this.password = password;
}
public void processUserIdAndPassword(String userId, String password) throws
JsonProcessingException {
Client client = ClientBuilder.newClient();
WebTarget webTarget = client.target(Constants.BASE_URL).path
("/rest/usersetting").path(this.userId).path("-").path(String
.valueOf(565));
Response res = webTarget.request(MediaType.TEXT_PLAIN).cookie(sessionCookie).get();
if (res.getStatus() == 200) {
String s = res.readEntity(String.class);
LanguageBean bean = TestUtil.extractObjectFromPayload(s, LanguageBean.class);
this.languageCode = bean.getLanguageCode();
this.variantCode = bean.getVariantCode();
this.countryCode = bean.getCountryCode();
}
}
public String getLanguageCode() { return this.languageCode; }
public String getCountryCode() { return this.countryCode; }
public String getVariantCode() { return this.variantCode; }
}
FitNesse Test is as below:
!path C:\Projects\webservice\ws-test\target\classes
!2 Scenario Definition
!|scenario |User Language |userId||password||languageCode||countryCode||variantCode|
|processUserIdAndPassword;|@userId |@password |
|check |getLanguageCode;|@languageCode |
|check |getCountryCode; |@countryCode |
|check |getVariantCode; |@variantCode |
!2 Test run
!|script|c.b.mc.fixture.UserLanguageFixture|userId|password|
!|User Language |
|# description|userId |password|languageCode|countryCode|variantCode|
|Test 01 |IUSER| |en |null |null |
I have carefully verified that the Fixture UserLanguageTest.class exist in the jar file in the target and also in the classes sub-folder of the target folder.
The strange part is, I have written another Fixture in the same package and have written simialr FitNesse Test for that. There FitNesse is able to find the Fixture.
Could someone please point out what could be going wrong here ? What can I check more ? The Error I get is:
script com.b.m.fixture.UserLanguageFixture Could not invoke constructor for c.b.m.fixture.UserLanguageFixture[2]
I managed to solve the problem simply by making constructors public. Having public constructors is very important in FitNesse Test.
public UserLanguageFixture(String userId, String password) {
this.userId = userId;
this.password = password;
}
public UserLanguageFixture() {
}