Xamarin.명령줄에서 Android Unit 테스트 수행
12854 단어 Xamarin.Android
절차.
안드로이드를 이용한 Instrumentation
1. TestInstrumentation 클래스의 설치
Xamarin.안드로이드의 Unit Test는 Instrumentation에
TestSuiteInstrumentation
클래스를 제공하고, 이를 계승한 클래스만 테스트 항목에 추가합니다.using System;
using Android.App;
using Android.OS;
using Android.Runtime;
using Xamarin.Android.NUnitLite;
[Instrumentation(Name = "uitestapp1.uitestapp1.TestInstrumentation")]
public class TestInstrumentation : TestSuiteInstrumentation
{
public TestInstrumentation(IntPtr handle, JniHandleOwnership transfer) : base (handle, transfer)
{
}
protected override void AddTests()
{
AddTest(Assembly.GetExecutingAssembly());
}
}
2. 시험의 집행TestSuiteInstrumentation
의 클래스가 부여한 Instrumentation
속성Name
이 지정한 값과 일치합니다.
adb shell am instrument -w UnitTestApp1.UnitTestApp1/uitestapp1.uitestapp1.TestInstrumentation
adb pull /data/user/0/UnitTestApp1.UnitTestApp1/files/.__override__/TestResults.xml ./TestResults.xml
테스트 결과 파일은 다음과 같은 XML 파일입니다.(nuit2 형식)
<?xml version="1.0" encoding="utf-8" standalone="no"?>
<!--This file represents the results of running a test suite-->
<test-results name="" total="5" errors="0" failures="1" not-run="1" inconclusive="1" ignored="1" skipped="0" invalid="0" date="2017-06-14" time="02:05:01">
<environment nunit-version="1.0.0.0" clr-version="4.0.50524.0" os-version="Unix 3.10.0.0" platform="Unix" cwd="/" machine-name="localhost" user="somebody" user-domain="localhost" />
<culture-info current-culture="ja-JP" current-uiculture="ja-JP" />
<test-suite type="TestSuite" name="" executed="True" result="Failure" success="False" time="0.049" asserts="2">
<failure>
<message><![CDATA[One or more child tests had errors]]></message>
<stack-trace />
</failure>
<results>
<test-suite type="Assembly" name="/storage/emulated/0/Android/data/UnitTestApp1.UnitTestApp1/files/.__override__/UnitTestApp1.dll" executed="True" result="Failure" success="False" time="0.046" asserts="2">
<properties>
<property name="_PID" value="1200" />
<property name="_APPDOMAIN" value="RootDomain" />
</properties>
<failure>
<message><![CDATA[One or more child tests had errors]]></message>
<stack-trace />
</failure>
<results>
<test-suite type="TestFixture" name="TestsSample" executed="True" result="Failure" success="False" time="0.035" asserts="2">
<failure>
<message><![CDATA[One or more child tests had errors]]></message>
<stack-trace />
</failure>
<results>
<test-case name="Fail" executed="True" result="Failure" success="False" time="0.019" asserts="1">
<failure>
<message><![CDATA[ Expected: False
But was: True
]]></message>
<stack-trace><![CDATA[ at UnitTestApp1.TestsSample.Fail () [0x00001] in <3474bbfc30d04efc9adb490971b61d70>:0
at (wrapper managed-to-native) System.Reflection.MonoMethod:InternalInvoke (System.Reflection.MonoMethod,object,object[],System.Exception&)
at System.Reflection.MonoMethod.Invoke (System.Object obj, System.Reflection.BindingFlags invokeAttr, System.Reflection.Binder binder, System.Object[] parameters, System.Globalization.CultureInfo culture) [0x00032] in <3fd174ff54b146228c505f23cf75ce71>:0
]]></stack-trace>
</failure>
</test-case>
<test-case name="Ignore" executed="False" result="Ignored">
<properties>
<property name="_SKIPREASON" value="another time" />
</properties>
<reason>
<message><![CDATA[another time]]></message>
</reason>
</test-case>
<test-case name="Inconclusive" executed="True" result="Inconclusive" success="False" time="0.001" asserts="0" />
<test-case name="NewTest" executed="True" result="Success" success="True" time="0" asserts="0" />
<test-case name="Pass" executed="True" result="Success" success="True" time="0.002" asserts="1" />
</results>
</test-suite>
</results>
</test-suite>
</results>
</test-suite>
</test-results>
Reference
이 문제에 관하여(Xamarin.명령줄에서 Android Unit 테스트 수행), 우리는 이곳에서 더 많은 자료를 발견하고 링크를 클릭하여 보았다 https://qiita.com/tafuji/items/51c66671977371ad7b28텍스트를 자유롭게 공유하거나 복사할 수 있습니다.하지만 이 문서의 URL은 참조 URL로 남겨 두십시오.
우수한 개발자 콘텐츠 발견에 전념 (Collection and Share based on the CC Protocol.)