FitNessse 测试找不到 Fixture
FitNessse Test can not find Fixture
我已经为该夹具编写了以下 Fixture 和 FitnessTest,但不知何故 FitNesse 无法找到该夹具。我只是提供用户名和密码(故意留空),然后检查该用户的语言代码、国家代码和变体代码:
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 测试如下:
!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 |
我已经仔细验证了目标中的jar文件中以及目标文件夹的类子文件夹中存在Fixture UserLanguageTest.class。
奇怪的是,我在同一个包中编写了另一个 Fixture,并为此编写了 simialr FitNesse Test。 FitNesse 可以在那里找到 Fixture。
有人可以指出这里可能出了什么问题吗?我还能检查什么?我得到的错误是:
script com.b.m.fixture.UserLanguageFixture Could not invoke constructor for c.b.m.fixture.UserLanguageFixture[2]
我设法简单地通过创建 构造函数 public 来解决问题。拥有 public 个构造函数在 FitNesse 测试中非常重要。
public UserLanguageFixture(String userId, String password) {
this.userId = userId;
this.password = password;
}
public UserLanguageFixture() {
}
我已经为该夹具编写了以下 Fixture 和 FitnessTest,但不知何故 FitNesse 无法找到该夹具。我只是提供用户名和密码(故意留空),然后检查该用户的语言代码、国家代码和变体代码:
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 测试如下:
!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 |
我已经仔细验证了目标中的jar文件中以及目标文件夹的类子文件夹中存在Fixture UserLanguageTest.class。
奇怪的是,我在同一个包中编写了另一个 Fixture,并为此编写了 simialr FitNesse Test。 FitNesse 可以在那里找到 Fixture。
有人可以指出这里可能出了什么问题吗?我还能检查什么?我得到的错误是:
script com.b.m.fixture.UserLanguageFixture Could not invoke constructor for c.b.m.fixture.UserLanguageFixture[2]
我设法简单地通过创建 构造函数 public 来解决问题。拥有 public 个构造函数在 FitNesse 测试中非常重要。
public UserLanguageFixture(String userId, String password) {
this.userId = userId;
this.password = password;
}
public UserLanguageFixture() {
}