Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions src/commands/test/generate/uitest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ export default class GenerateUITestCommand extends GenerateCommand {

protected async processTemplate(): Promise<void> {
const platform = this.isIOS() ? "iOS" : "Android";
const packageFilePath = path.join(this.outputPath, `AppCenter.UITest.${platform}/packages.config`);
const projectFilePath = path.join(this.outputPath, `AppCenter.UITest.${platform}/AppCenter.UITest.${platform}.csproj`);

let latestVersion: string;
Expand All @@ -29,11 +28,12 @@ export default class GenerateUITestCommand extends GenerateCommand {
}

try {
// Replace version inside packages.config file
await this.replaceVersionInFile(packageFilePath, /(id="Xamarin\.UITest" version=")(\d+(\.\d+)+)/, latestVersion);

// Replace version inside *.csproj file
await this.replaceVersionInFile(projectFilePath, /(packages\\Xamarin\.UITest\.)(\d+(\.\d+)+)/, latestVersion);
await this.replaceVersionInFile(
projectFilePath,
/(<PackageReference Include="Xamarin\.UITest" Version=")(\d+(\.\d+)+)/,
latestVersion
);
} catch (e) {
await this.copyTemplates();
console.warn("Can't update UITest version. Using default templates. Details: " + e);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,12 @@
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="..\packages\NUnit.3.12.0\build\NUnit.props" Condition="Exists('..\packages\NUnit.3.12.0\build\NUnit.props')" />
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProjectGuid>{845DEB90-8D90-47F6-9DAA-F07E68DCE9CF}</ProjectGuid>
<OutputType>Library</OutputType>
<RootNamespace>AppCenter.UITest.Android</RootNamespace>
<AssemblyName>AppCenter.UITest.Android</AssemblyName>
<TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
<TargetFrameworks>net6.0;net462</TargetFrameworks>
<GenerateAssemblyInfo>false</GenerateAssemblyInfo>
<LangVersion>10.0</LangVersion>
<Deterministic>false</Deterministic>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
Expand All @@ -28,20 +26,7 @@
<ConsolePause>false</ConsolePause>
</PropertyGroup>
<ItemGroup>
<Reference Include="System" />
<Reference Include="Xamarin.UITest">
<HintPath>..\packages\Xamarin.UITest.3.2.2\lib\net45\Xamarin.UITest.dll</HintPath>
</Reference>
<Reference Include="nunit.framework">
<HintPath>..\packages\NUnit.3.12.0\lib\net45\nunit.framework.dll</HintPath>
</Reference>
<PackageReference Include="NUnit" Version="3.13.3" />
<PackageReference Include="Xamarin.UITest" Version="4.1.0" />
</ItemGroup>
<ItemGroup>
<Compile Include="Tests.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
</ItemGroup>
<ItemGroup>
<None Include="packages.config" />
</ItemGroup>
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
</Project>

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,14 +1,12 @@
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="..\packages\NUnit.3.12.0\build\NUnit.props" Condition="Exists('..\packages\NUnit.3.12.0\build\NUnit.props')" />
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProjectGuid>{764CE893-AF50-456A-8263-2675A94D96DF}</ProjectGuid>
<OutputType>Library</OutputType>
<RootNamespace>AppCenter.UITest.iOS</RootNamespace>
<AssemblyName>AppCenter.UITest.iOS</AssemblyName>
<TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
<TargetFrameworks>net6.0;net462</TargetFrameworks>
<GenerateAssemblyInfo>false</GenerateAssemblyInfo>
<LangVersion>10.0</LangVersion>
<Deterministic>false</Deterministic>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
Expand All @@ -28,20 +26,7 @@
<ConsolePause>false</ConsolePause>
</PropertyGroup>
<ItemGroup>
<Reference Include="System" />
<Reference Include="Xamarin.UITest">
<HintPath>..\packages\Xamarin.UITest.3.2.2\lib\net45\Xamarin.UITest.dll</HintPath>
</Reference>
<Reference Include="nunit.framework">
<HintPath>..\packages\NUnit.3.12.0\lib\net45\nunit.framework.dll</HintPath>
</Reference>
<PackageReference Include="NUnit" Version="3.13.3" />
<PackageReference Include="Xamarin.UITest" Version="4.1.0" />
</ItemGroup>
<ItemGroup>
<Compile Include="Tests.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
</ItemGroup>
<ItemGroup>
<None Include="packages.config" />
</ItemGroup>
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
</Project>

This file was deleted.

29 changes: 4 additions & 25 deletions test/commands/test/generate/uitest-test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,14 +45,13 @@ describe("Validating UITest template generation", () => {
)
).to.be.true;
expect(await pfs.exists(path.join(command.outputPath, `AppCenter.UITest.${command.platform}/Tests.cs`))).to.be.true;
expect(await pfs.exists(path.join(command.outputPath, `AppCenter.UITest.${command.platform}/packages.config`))).to.be.true;
expect(await pfs.exists(path.join(command.outputPath, `AppCenter.UITest.${command.platform}/Properties/AssemblyInfo.cs`))).to.be
.true;
});

it("should update NuGet version", async () => {
const fakeLatestVersion = "3.14.0";
// Arrange
const fakeLatestVersion = "2.5.6";
const args: CommandArgs = {
command: ["test", "generate", "uitest"],
commandPath: "Test",
Expand All @@ -66,31 +65,25 @@ describe("Validating UITest template generation", () => {
});
});

const packageFilePath = path.join(command.outputPath, `AppCenter.UITest.${command.platform}/packages.config`);
const projectFilePath = path.join(
command.outputPath,
`AppCenter.UITest.${command.platform}/AppCenter.UITest.${command.platform}.csproj`
);

// Assert
let packageFileContent = await pfs.readFile(packageFilePath, "utf8");
expect(packageFileContent).not.contain(fakeLatestVersion);

let projectFileContent = await pfs.readFile(projectFilePath, "utf8");
expect(projectFileContent).not.contain(fakeLatestVersion);

// Act
await (command as any).processTemplate();

// Assert
packageFileContent = await pfs.readFile(packageFilePath, "utf8");
expect(packageFileContent).contain(fakeLatestVersion);

projectFileContent = await pfs.readFile(projectFilePath, "utf8");
expect(projectFileContent).contain(fakeLatestVersion);
});

it("should not touch NuGet version on failure", async () => {
const latestVersion = "4.1.0";
// Arrange
const args: CommandArgs = {
command: ["test", "generate", "uitest"],
Expand All @@ -105,28 +98,21 @@ describe("Validating UITest template generation", () => {
});
});

const packageFilePath = path.join(command.outputPath, `AppCenter.UITest.${command.platform}/packages.config`);
const projectFilePath = path.join(
command.outputPath,
`AppCenter.UITest.${command.platform}/AppCenter.UITest.${command.platform}.csproj`
);

// Assert
let packageFileContent = await pfs.readFile(packageFilePath, "utf8");
expect(packageFileContent).contain("3.2.2");

let projectFileContent = await pfs.readFile(projectFilePath, "utf8");
expect(projectFileContent).contain("3.2.2");
expect(projectFileContent).contain(latestVersion);

// Act
await (command as any).processTemplate();

// Assert
packageFileContent = await pfs.readFile(packageFilePath, "utf8");
expect(packageFileContent).contain("3.2.2");

projectFileContent = await pfs.readFile(projectFilePath, "utf8");
expect(projectFileContent).contain("3.2.2");
expect(projectFileContent).contain(latestVersion);
});

it("should recover original template files on failure", async () => {
Expand Down Expand Up @@ -155,26 +141,19 @@ describe("Validating UITest template generation", () => {
});
});

const packageFilePath = path.join(command.outputPath, `AppCenter.UITest.${command.platform}/packages.config`);
const projectFilePath = path.join(
command.outputPath,
`AppCenter.UITest.${command.platform}/AppCenter.UITest.${command.platform}.csproj`
);

// Assert
let packageFileContent = await pfs.readFile(packageFilePath, "utf8");
expect(packageFileContent).not.contain(fakeLatestVersion);

let projectFileContent = await pfs.readFile(projectFilePath, "utf8");
expect(projectFileContent).not.contain(fakeLatestVersion);

// Act
await (command as any).processTemplate();

// Assert
packageFileContent = await pfs.readFile(packageFilePath, "utf8");
Comment thread
thewulf7 marked this conversation as resolved.
expect(packageFileContent).not.contain(fakeLatestVersion);

projectFileContent = await pfs.readFile(projectFilePath, "utf8");
expect(projectFileContent).not.contain(fakeLatestVersion);
});
Expand Down