Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Objects: Adds tests to CI job #1621

Merged
merged 12 commits into from Sep 21, 2022
21 changes: 16 additions & 5 deletions .circleci/scripts/config-template.yml
Expand Up @@ -73,17 +73,28 @@ jobs: # Each project will have individual jobs for each specific task it has to
- codecov/upload

build-objects:
executor:
name: win/default
shell: powershell.exe
docker:
- image: "mcr.microsoft.com/dotnet/core/sdk" # dotnet core 3.1 sdk
- image: "mcr.microsoft.com/dotnet/core/sdk:2.1-focal" # dotnet core 2.1 sdk (for netstandard support on build)
steps:
- checkout
- run:
name: Restore Objects
command: nuget restore Objects/Objects.sln
command: dotnet restore Objects/Objects.sln
- run:
name: Build Objects
command: msbuild Objects/Objects.sln /p:Configuration=Release /p:WarningLevel=0 /p:IsDesktopBuild=false
command: dotnet build --no-restore Objects/Objects/Objects.csproj -c Release /p:WarningLevel=0 /p:IsDesktopBuild=false
- run:
name: Test Objects
command: dotnet test Objects/Tests/Tests.csproj --no-restore -c Release -v q --logger:"junit;LogFileName={assembly}.results.xml" --results-directory=TestResults --collect:"XPlat Code Coverage" -- DataCollectionRunSettings.DataCollectors.DataCollector.Configuration.Format=opencover
- store_test_results:
path: TestResults
- store_artifacts:
path: TestResults
# Upload to codecov if necessary
# Currently disabled until we figure out a strategy to
# upload Core and Objects at once
# - codecov/upload

build-desktopui:
executor: # Using a win executor since there are post-steps in the nuget workflow that use powershell
Expand Down
34 changes: 34 additions & 0 deletions Objects/Tests/GenericTests.cs
@@ -0,0 +1,34 @@
using System;
using System.Collections;
using System.Collections.Generic;
using System.Drawing;
using System.Linq;
using System.Reflection;
using NUnit.Framework;
using Objects;
using Objects.Geometry;
using Speckle.Core.Kits;
using Speckle.Core.Models;

namespace Tests
{
[TestFixture]
public class GenericTests
{
public static IEnumerable AvailableTypesInKit()
{
// Get all types in the Objects assembly that inherit from Base
return Assembly.GetAssembly(typeof(ObjectsKit))
.GetTypes()
.Where(t => typeof(Base).IsAssignableFrom(t));
}

[Test(Description = "Checks that all objects inside the Default Kit have empty constructors.")]
[TestCaseSource(nameof(AvailableTypesInKit))]
public void ObjectHasEmptyConstructor(Type t)
{
var constructor = t.GetConstructor(Type.EmptyTypes);
Assert.That(constructor, Is.Not.Null);
}
}
}
5 changes: 3 additions & 2 deletions Objects/Tests/Tests.csproj
@@ -1,8 +1,8 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>net5.0</TargetFramework>

<TargetFramework>netcoreapp3.1</TargetFramework>
<LangVersion>9.0</LangVersion>
<IsPackable>false</IsPackable>
</PropertyGroup>

Expand All @@ -11,6 +11,7 @@
<PackageReference Include="NUnit" Version="3.13.1" />
<PackageReference Include="NUnit3TestAdapter" Version="3.17.0" />
<PackageReference Include="coverlet.collector" Version="3.0.2" />
<PackageReference Include="JunitXml.TestLogger" Version="3.0.114" />
</ItemGroup>

<ItemGroup>
Expand Down