TestServer를 설정하고 요청을 작성하고 응답의 유효성을 검사하는 작업 단위 테스트를하고 있습니다.mstest.exe에서 OWIN TestServer를 시작하십시오.
Visual Studio Test Explorer에서 단위 테스트를 실행하면 잘 작동합니다. TestServer가 설정되고 요청이 작성되고 올 Y 른 응답이 리턴됩니다.
명령 줄 (CI 서버에서)에서 동일한 코드를 실행할 때 TestServer는 항상 "찾을 수 없음"에 대한 상태 코드를 반환합니다. 다른 예외는 없습니다. 명령 줄에서 OWIN을 시작할 때 추가해야하는 명령이 있습니까? 내가 말했듯이, 테스트가 비주얼 스튜디오 내에서 잘 작동
[TestMethod]
public async Task GetToken()
{
using (var server = TestServer.Create<TestStartupConfiguration>())
{
var response = await server.CreateRequest("/TokenUrl").And(x => x.Content = new FormUrlEncodedContent(new[]
{
new KeyValuePair<string, string>("username", user.UserName),
new KeyValuePair<string, string>("password", user.Password),
new KeyValuePair<string, string>("grant_type", "password")
})).PostAsync();
response.IsSuccessStatusCode.Should().BeTrue("this is the expected return value of an Access Token request");
var responseString = await response.Content.ReadAsStringAsync();
responseString.Should().NotBeNullOrWhiteSpace("the response of an Access Token request should not be empty");
}
}
을 그리고 :
MSTest.exe /testcontainer:myTests.dll /resultsfile:testresults.trx
내 시험 방법은 다음과 같습니다
MSTest.exe 명령은 다음과 같습니다. 그리고 다른 모든 단위 테스트는 명령 줄에서 예상대로 실행됩니다.
고맙습니다.
빌드 설정이 NuGet 패키지를 복원합니까? – toadflakz