나는 AutoFixture, NSubstitute 및 xUnit으로 단위 테스트를하고 있습니다.NS substitute - 동일한 유형의 모든 인수에 대한 사양을 사용하십시오. TeamCity 문제
VS에서 로컬 dev 컴퓨터를 전달하지만 TeamCity에서 실패합니다.
테스트 :
[Theory, AutoNSubstituteData]
public async void GetList_StatusError_ShouldReturnBadRequest(
[Frozen] ICommentsService _commentsService,
[Frozen] IMerchantsService _merchantsService,
[Frozen] ICampaignsService _campaignsService)
{
// Arrange
var output = _fixture.Build<CommentsResult<CommentOutput>>()
.Without(w => w.Entity)
.With(x => x.Status, ServiceActionStatus.Error)
.Create();
_commentsService.List(Arg.Any<int>(), Arg.Any<string>()).Returns(output);
var controller = new CommentController(_commentsService, _merchantsService, _campaignsService);
controller.Request = new HttpRequestMessage();
controller.Configuration = new HttpConfiguration();
// Act
IHttpActionResult actionResult = await controller.GetList(null);
var contentResult = actionResult as BadRequestErrorMessageResult;
// Assert
contentResult.Should().NotBeNull();
contentResult.Message.Should().NotBeNullOrEmpty();
}
인 TeamCity 오류 :
public class CommentsResult<T> : IServiceResult<T>
{
public T Entity { get; set; }
public string Message { get; set; }
public Exception Exception { get; set; }
public ServiceActionStatus Status { get; set; }
}
무엇을 할 수있다 :
NSubstitute.Exceptions.AmbiguousArgumentsException:
Cannot determine argument specifications to use.
Please use specifications for all arguments of the same type. at NSubstitute.Core.Arguments.NonParamsArgumentSpecificationFactory.Create(Object argument, IParameterInfo parameterInfo, ISuppliedArgumentSpecifications suppliedArgumentSpecifications)
모습 CommentsResult?
다음은 [일반적인 문제를 진단하는 방법에 대한 정보]입니다 (http://stackoverflow.com/a/26856185/906). TC에서 테스트가 다른 순서로 실행 중이고 문제가 노출되고 있습니까? –