java断言错误_java-获取断言错误,即使期望值和实际值相同
在以下斷言錯(cuò)誤中需要幫助.
當(dāng)我進(jìn)行以下API調(diào)用時(shí),盡管實(shí)際值和預(yù)期值都相同,但我卻收到了此異常.
import com.jayway.restassured.RestAssured;
import com.jayway.restassured.RestAssured.*;
import com.jayway.restassured.matcher.RestAssuredMatchers.*;
import org.hamcrest.Matchers.*;
import static org.hamcrest.Matchers.*;
public class firstRestCall
{
public static void main(String[] args)
{
RestAssured.get("http://restcountries.eu/rest/v1/name/Norway").
then().
body("capital",equalTo("Oslo"));
//body("capital",equalTo("[Oslo]")); tried this also, but getting the same exception
}
}
輸出:
Exception in thread "main" java.lang.AssertionError: 1 expectation failed.
JSON path capital doesn't match.
Expected: Oslo
Actual: [Oslo]
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source) etc....
總結(jié)
以上是生活随笔為你收集整理的java断言错误_java-获取断言错误,即使期望值和实际值相同的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問(wèn)題。
- 上一篇: 分区界限必须调整为高于最后一个分区界限_
- 下一篇: java动态代理_Java中的动态代理一