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

Feature: Add targetPlatform for tests #189

Open
skjalgsm-statespace opened this issue Jul 7, 2022 · 1 comment
Open

Feature: Add targetPlatform for tests #189

skjalgsm-statespace opened this issue Jul 7, 2022 · 1 comment
Labels
enhancement New feature or request

Comments

@skjalgsm-statespace
Copy link
Contributor

skjalgsm-statespace commented Jul 7, 2022

Context

Since we are targeting multiple platforms with several different defines (such as #if UNITY_IOS and #if UNITY_ANDROID) in our code base I would like to run tests while targeting these platforms. Currently only the UNITY_LINUX_STANDALONE define is set when running tests on an ubuntu runner.

This would make it so much easier to catch those simple compile mistakes when PR's lands too.

Suggested solution

I suggest that -targetPlatform is added as an option. This option would then require the unity project to have a static RunTest (or something similar) method also defined in a -testMethod option (similar to how -buildMethod works for game-ci/unity-builder).

That testMethod would then need to look something like this (in an editor folder):

public static void RunTest()
{
    var testRunnerApi = ScriptableObject.CreateInstance<TestRunnerApi>();
    var filter = new Filter()
    {
        testMode = GetTestMode("-testPlatform"),
        targetPlatform = GetBuildTarget("-targetPlatform")
    };
    testRunnerApi.Execute(new ExecutionSettings(filter));
}

Additional details

https://docs.unity3d.com/Packages/com.unity.test-framework@1.1/manual/extension-run-tests.html

@webbertakken
Copy link
Member

Thanks for creating this issue. We agree this would be nice to have as well.

If I remember correctly, this has been requested before but no pull request was ever created.
Note that it's not the ubuntu runner that decides which platforms are available, but the docker image that's used inside the action. Unity-builder already supports multiple targetPlatforms (most can be used without having to change runner type).

In test runner currently there's only customImage, which can be used to use the iOS, Android or other image (see versions for the respective image tags). I believe this was already enough for the people that needed this, though ultimately we'd want to support a parameter targetPlatform exactly in the same way as we do in unity-builder.

Accepting PRs for this.

@davidmfinol davidmfinol added the enhancement New feature or request label Sep 9, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

3 participants