使用 PACT 时如何在 httptarget 方法中传递 url

在创建协议验证测试时,我正在使用 httpTarget 方法。但问题是我的服务没有端口值。我们如何运行它?请指教。服务 URL= http://services.groupkt.com/country/get/iso3code/IND


下面是我的验证测试。包 se.ff.bsv;


import au.com.dius.pact.provider.junit.PactRunner;

import au.com.dius.pact.provider.junit.Provider;

import au.com.dius.pact.provider.junit.State;

import au.com.dius.pact.provider.junit.loader.PactFolder;

import au.com.dius.pact.provider.junit.loader.PactUrl;

import au.com.dius.pact.provider.junit.target.HttpTarget;

import au.com.dius.pact.provider.junit.target.Target;

import au.com.dius.pact.provider.junit.target.TestTarget;

import org.junit.Before;

import org.junit.BeforeClass;

import org.junit.ClassRule;

import org.junit.runner.RunWith;


import java.net.URL;

import java.util.Map;


@RunWith(PactRunner.class) // Say JUnit to run tests with custom Runner

@Provider("getCountryService") // Set up name of tested provider

@PactFolder("../pacts") // Point where to find pacts (See also section Pacts source in documentation)


//@PactUrl(urls = {"http://services.groupkt.com/country/get/iso3code/IND"} )


public class getCountryContractTest {


    @State("There is a country with alpha2_code as IN having name as India") // Method will be run before testing

                                                                                // interactions that require "with-data"

                                                                                // state

    public void hammerSmith() {

        System.out.println("There is a country with alpha2_code as IN having name as India");

    }


    @TestTarget // Annotation denotes Target that will be used for tests


    //public final Target target = new HttpTarget(8111);// Out-of-the-box implementation of Target (for more information take a look at Test Target section)

    public final Target target = new HttpTarget("http", "services.groupkt.com",);


}


慕森王
浏览 89回答 1
1回答

月关宝盒

您不能说您的服务没有端口,但您可以说您的服务使用默认端口(例如)。在这种情况下,请尝试使用端口 80。
打开App,查看更多内容
随时随地看视频慕课网APP

相关分类

Java