我最近创建了一个带有新单元测试的新单元测试项目。我下载了RestAssured nuget,并从以下位置复制并粘贴了教程代码:
https://github.com/lamchakchan/RestAssured.Net
using Microsoft.VisualStudio.TestTools.UnitTesting;
using RA;
namespace RestAssuredTests
{
[TestClass]
public class UnitTest1
{
[TestMethod]
public void TestMethod1()
{
new RestAssured()
.Given()
//Optional, set the name of this suite
.Name("JsonIP Test Suite")
//Optional, set the header parameters.
//Defaults will be set to application/json if none is given
.Header("Content-Type", "application/json")
.Header("Accept-Encoding", "gzip,deflate")
.When()
//url
.Get("http://jsonip.com")
.Then()
//Give the name of the test and a lambda expression to test with
//The lambda expression keys off of 'x' which represents the json blob as a dynamic.
.TestBody("test a", x => x.about != null)
//Throw an AssertException if the test case is false.
.Assert("test a");
}
}
}
我运行它时出现错误:
Message: Test method RestAssuredTests.UnitTest1.TestMethod1 threw exception:
System.TypeLoadException: Could not load type 'RA.RestAssured' from assembly 'RestAssured, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null'.
有人知道为什么会发生此错误吗?我已经重新安装了nuget并关闭并重新启动VS2017无济于事。
亲切的问候, 拉胡尔·迪克西特(Rahul Dixit)