NUnit 테스트 러너에서 specflow를 사용하고 있습니다.테스트중인 애플리케이션에 대한 참조를 얻으려면 어떻게해야합니까?
using System;
using TechTalk.SpecFlow;
using Xamarin.UITest.Android;
namespace UITest1
{
[Binding]
public class CategoryPagerSteps
{
[Given(@"The (.*)st category is selected")]
public void GivenTheStCategoryIsSelected(int p0)
{
ScenarioContext.Current.Pending();
}
[When(@"I swipe left")]
public void WhenISwipeLeft()
{
ScenarioContext.Current.Pending();
}
[Then(@"The (.*)nd category is selected")]
public void ThenTheNdCategoryIsSelected(int p0)
{
ScenarioContext.Current.Pending();
}
}
}
이 괜찮습니다, 나는 이러한 시나리오 때 내 오이 파일 호출됩니다 "단계"것으로 알고 있습니다 : 내 기능 파일을 작성하고 단계를 생성하는 specflow를 물어 보면, 다음과 같은 코드를 출력 작은 오이 (Gherkin)에 적혀 있습니다.
그러나 이것은 완전히 통합 된 UI 테스트이므로 Xamarin.UITest.Android를 사용하여보기 등을 클릭 할 수 있어야합니다.
그래서 어떻게 든 UI 테스트를 수행 할 수 있도록 테스트중인 응용 프로그램을 나타내는 개체를 잡아야합니다. 재산 AndroidApp app
내가 필요로하는 객체입니다
using NUnit.Framework;
using Xamarin.UITest;
using Xamarin.UITest.Android;
namespace UITest1
{
[TestFixture]
public class Tests
{
AndroidApp app;
[SetUp]
public void BeforeEachTest()
{
// TODO: If the Android app being tested is included in the solution then open
// the Unit Tests window, right click Test Apps, select Add App Project
// and select the app projects that should be tested.
app = ConfigureApp
.Android
// TODO: Update this path to point to your Android app and uncomment the
// code if the app is not included in the solution.
//.ApkFile ("../../../Android/bin/Debug/UITestsAndroid.apk")
.StartApp();
}
[Test]
public void AppLaunches()
{
app.Screenshot("First screen.");
}
}
}
내가 볼 수 있습니다
지금, 나는이 객체가 "Tests.cs"라는 또 다른 자동 생성 된 테스트 픽스처 파일에서 초기화되고 있음을 볼 수있다 에 액세스 할 수 있지만 위의 코드 CategoryPagerSteps
에서 해당 속성에 액세스하려면 어떻게해야합니까? Tests
은 정적도 아니며 메서드 또는 속성 중 하나입니다. 아마도 테스트 주자가 수행해야하기 때문에 간단하게 인스턴스화하는 것이 불안합니다. 맞습니까? 다른 자동 생성 파일 중 하나는 testRunner 특성을 포함하지만 private로 표시됩니다.
그래서 내가 간 모든 애비뉴가 막힌 것처럼 보입니다. 나는 분명히 뭔가 빠져 있다고 느낍니다.
arteksoftware에서 @CheeseBaron에서 제공하는 link 위로 다음, 트릭 값을 보유하는 SpecFlow의 FeatureContext.Current
을 사용하는 것입니다
에서보세요이 문서가 심도있게 설명 http://arteksoftware.com/bdd-tests-with-xamarin-uitest-and-specflow/ SpecFlow + Xamarin.UITest를 시작하는 방법 – Cheesebaron