доброе утро / день / вечер
Я строю решение C # с одним проектом, используя тесты NUnit, и другим проектом, используя тесты Xamarin.
Я пытаюсь использовать переменную из моего проекта NUnit/ class в моем проекте / классе Xamarin, но я не могу этого сделать.
Если я запускаю свои тесты NUnit без моих тестов xamarin, то работает нормально.
Если я запускаю свои тесты Xamarin, комментируя всеиз NUnit, xamarin работает нормально.
Но если я запускаю Xamarin с вызовом NUnit, все тесты не пройдены.Даже тесты не используют NUnit.
Это мое сообщение об ошибке: Сообщение: OneTimeSetUp: System.ArgumentNullException: значение не может быть нулевым. Имя параметра: ключ
Это код изUNIT Test class
using Microsoft.VisualStudio.TestTools.UnitTesting;
using System;
using System.Linq;
using System.Configuration;
namespace UnitTestProject1
{
[TestClass]
class TC_TRACK_ADMIN_ENTITY_DEVICE
{
//Instanciate test conditions
SetupTest setupTest = new SetupTest();
public string deviceActivationCode;
[TestMethod]
[TestCategory("End-to-End")]
public void GetDeviceActivationCode()
{
//Initialize test
setupTest.Initialize();
//Login to Application
LoginPageObjects loginPage = new LoginPageObjects();
HomePageObjects HomePage = loginPage.Login(UserRoles.SystemAdministrator);
DevicesPageObjects DevicePage = HomePage.SelectDevicesOption();
WebdriverExtensions.WaitForElementToBeDisplayed(DevicePage.DeviceListTable);
//Select a Tracking Location
HomePage.SelectTrackingLocationFromDropBox(ConfigurationManager.AppSettings["TrackingLocationCode_1"]);
//Device Creation page
DevicePage.NewDevice.Click();
CreateDevicePageObjects CreateNewDevice = new CreateDevicePageObjects();
WebdriverExtensions.WaitForElementToBeDisplayed(CreateNewDevice.SaveButton);
//Random generator for creating new entries
Random random = new Random();
int i = random.Next(0, 10000);
string DeviceCode = ConfigurationManager.AppSettings["DeviceForMobileAutomation"] + i;
//Create a new device
CreateNewDevice.NewDevice(DeviceCode);
//Check all the device roles
CreateNewDevice.CheckAllNewDeviceRoles();
WebdriverExtensions.WaitForElementToBeDisplayed(CreateNewDevice.DeviceActivation);
deviceActivationCode = CreateNewDevice.DeviceActivationCode.Text;
Console.WriteLine(deviceActivationCode);
setupTest.Cleanup();
}
}
}
А это мой тестовый класс Xamarin
using System;
using System.IO;
using System.Linq;
using NUnit.Framework;
using Xamarin.UITest;
using Xamarin.UITest.Queries;
using UnitTestProject1;
using System.Collections.Generic;
using System.Text;
using System.Threading.Tasks;
namespace Anderson
{
class XamarinTest
{
[TestFixture(Platform.Android)]
//[TestFixture(Platform.iOS)]
public class Tests
{
IApp app;
Platform platform;
TC_TRACK_ADMIN_ENTITY_DEVICE getCode = new TC_TRACK_ADMIN_ENTITY_DEVICE();
public Tests(Platform platform)
{
this.platform = platform;
}
[SetUp]
public void BeforeEachTest()
{
app = AppInitializer.StartApp(platform);
}
[Test]
public void CodeApplied()
{
if (app.Query("Welcome to").Any())
{
Console.WriteLine(" STARTING ENROLLMENT FAILL AND PASS! ");
Console.WriteLine(" Começando o Enrollment Falha e Passa! ");
EnrollmentFaillAndPass();
}
else
{
if (app.Equals("android.widget.TextView"))
{
Console.WriteLine(" STARTING REGULAR TESTS! ");
Console.WriteLine(" Começando os testes regulares! ");
}
else
Console.WriteLine(" WHERE AM I? ");
Console.WriteLine(" Onde eu estou? ");
}
}
public void EnrollmentFaillAndPass()
{
EnrollmentFailedTest();
EnrollmentSuccessfulTest();
}
[Test]
public void EnrollmentFailedTest()
{
//Wait for enrollment screen
app.WaitForElement(w => w.Text("INEXTEND"), timeout: TimeSpan.FromSeconds(30));
app.Query("Welcome to").Any();
Console.WriteLine(" Found WELCOME text ");
Console.WriteLine(" Encontrado o texto WELCOME ");
//Type enrollment code
app.EnterText(x => x.Id("NoResourceEntry-8"), "1NV4L1DC0D3");
app.Tap(x => x.Text("Enroll"));
Console.WriteLine(" PUTING THE INVALID CODE ");
Console.WriteLine(" Colocando o código inválido ");
//Wait for enrollment process to finish
app.WaitForNoElement(x => x.Text("Generating certificate..."), timeout: TimeSpan.FromSeconds(60));
Console.WriteLine(" WAITING THE LOADING FINISH! ");
Console.WriteLine(" Esperando o Loading terminar! ");
//Assert
AppResult[] results = app.WaitForElement(x => x.Text("Device enrollment failed"), timeout: TimeSpan.FromSeconds(30));
Assert.IsTrue(results.Any());
Console.WriteLine(" CHECKING THE ENROLLMENT FAIL MESSAGE! ");
Console.WriteLine(" Verificando a mensagem de ENROLLMENT FAIL! ");
app.Tap(x => x.Text("Back to menu"));
Console.WriteLine(" BACKING TO THE MENU! ");
Console.WriteLine(" Voltando para o menu! ");
}
[Test]
public void EnrollmentSuccessfulTest()
{
Console.WriteLine("Checking Welcome text after invalid keycode");
Console.WriteLine("Verificando o texto de Welcome depois do código inválido");
app.WaitForElement(c => c.Text("Welcome to"));
Console.WriteLine("Welcome text confirmed");
Console.WriteLine("Texto Welcome confirmado");
Console.WriteLine("Cleaning the Keycode field");
Console.WriteLine("Limpando o campo Keycode");
getCode.GetDeviceActivationCode();
string validCode = getCode.deviceActivationCode;
Console.WriteLine("VALIDATION CODE: " + validCode);
Console.WriteLine("Código de validação: " + validCode);
//Type enrollment code
app.EnterText(x => x.Id("NoResourceEntry-8"), validCode);
Console.WriteLine(" PUTING THE VALID CODE ");
Console.WriteLine(" Colocando o código válido ");
app.Tap(x => x.Text("Enroll"));
Console.WriteLine("Tapping on Enroll with a valid Keycode");
Console.WriteLine("Clicando no Enrool do código válido");
}
}
}
Это AppInitializer
using System;
using Xamarin.UITest;
using Xamarin.UITest.Queries;
namespace Xamarin
{
public class AppInitializer
{
public static IApp StartApp(Platform platform)
{
if (platform == Platform.Android)
{
return ConfigureApp
.Android
.PreferIdeSettings()
.DeviceSerial("SamsungS9")
.ApkFile(@"C:/MyApp/MyApp.apk")
.StartApp(Xamarin.UITest.Configuration.AppDataMode.DoNotClear);
}
return ConfigureApp.iOS.StartApp();
}
}
}
Если кто-то знает что-то, чтобы помочь, я буду оченьрад.