FitNessse Test无法找到Fixture

时间:2017-10-20 13:07:51

标签: java constructor fitnesse-slim fixture

我已经为该灯具编写了以下Fixture和FitnessTest,但不知何故FitNesse无法找到Fixture。我只是提供用户名和密码(故意空白),然后检查该用户的语言代码,国家代码和变体代码:

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能够找到Fixture。

有人可以指出这里可能出现的问题吗?我还可以查看更多内容?我得到的错误是:

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

1 个答案:

答案 0 :(得分:0)

我设法通过将构建器公开来解决问题。拥有公共构造函数在FitNesse Test中非常重要。

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

    public UserLanguageFixture() {
    }