2017-10-20 44 views
0

我已经为该灯具写了以下Fixture和FitnessTest,但不知何故FitNesse无法找到灯具。我只需提供用户名和密码(空白故意),然后检查是否有语言代码,COUNTRYCODE和variantcode该用户:FitNessse测试找不到灯具

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  | 

我仔细验证Fixture UserLanguageTest.class存在于目标文件夹中的jar文件中,也存在于目标文件夹的classes子文件夹中。

奇怪的是,我已经在同一个软件包中编写了另一个Fixture,并为此写了simialr FitNesse Test。 FitNesse能够找到夹具。

有人请指出这里可能会出现什么问题吗?我可以检查更多什么?我得到的错误是:

script com.b.m.fixture.UserLanguageFixture Could not invoke constructor for c.b.m.fixture.UserLanguageFixture[2] 

回答

0

我设法通过简单地使构造公共来解决这个问题。拥有公共构造函数在FitNesse测试中非常重要。

public UserLanguageFixture(String userId, String password) { 
     this.userId = userId; 
     this.password = password; 
    } 

    public UserLanguageFixture() { 
    }