【问题标题】:FitNessse Test can not find FixtureFitNessse 测试找不到夹具
【发布时间】:2017-10-20 13:07:50
【问题描述】:

我已经为该夹具编写了以下夹具和 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       |

我已经仔细验证了 Fixture UserLanguageTest.class 存在于目标的 jar 文件中以及目标文件夹的 classes 子文件夹中。

奇怪的是,我在同一个包中编写了另一个 Fixture,并为此编写了类似的 FitNesse Test。 FitNesse 能够找到 Fixture。

有人可以指出这里可能出了什么问题吗?我还能检查什么?我得到的错误是:

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

【问题讨论】:

    标签: java constructor fitnesse-slim fixture


    【解决方案1】:

    我设法通过将构造函数公开解决了这个问题。在 FitNesse 测试中拥有公共构造函数非常重要。

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

    【讨论】:

      猜你喜欢
      • 2023-03-24
      • 1970-01-01
      • 2022-01-22
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多