Running Unity scripts from CI

Hi,

We’d like to test our unity scripts in our CI. We have a number of MonoBehaviour scripts that setup when Start is called and run when when Update is called.
S1) The first way to do this would be to simply add all the scripts into a scene. We would prefer not to do this as we cannot test the script individually and all the logging would be mixed.
S2) The next option would be to create a separate build with each build containing 1 scene with one of the scripts.
S3) The next option which I hope is possible but I ask about below, is to create 1 scene for each script, but include all scenes in a single build. Then when we invoke the standalone build, we can specify as an argument which scene will be used. Is this possible?

Details:
I was able to perform a standalone build from the command line with the following bat file.

set mypath=%cd%
@echo %mypath%
"C:\Program Files\Unity\Editor\Unity.exe" -quit -batchmode -logFile stdout.log -projectPath %mypath% -buildWindows64Player "builds\mygame.exe"

Q1) How does this standalone build choose which scene is included?
Q2) What files are required to exist at the projectPath specified?

I also noticed that a build can be performed with multiple scenes by using a custom build task such as

using UnityEditor;
using UnityEngine;
using System.Collections;
public class MyEditorScript: MonoBehaviour
{
      static void Start()
     {
        
         string[] scenes = {"Assets/scene1.unity",  "Assets/scene2.unity"};
         BuildPipeline.BuildPlayer(scenes, "StandaloneWindows64", BuildTarget.StandaloneWindows64, BuildOptions.None);
     }
}

Q3) How does unity choose which scene will be loaded when the standalone game is launched?
Q4) Is there a way to launch the exe and specify the scene to load via argument?

Thanks,
Justin

Q1: Regular Unity builds, in the editor or from the command line, use the scenes that are set in Build Settings.
Q2: The project path needs to be set to a Unity project. Do you want to generate one on the fly?
Q3: Unity builds will always start with the first scene, either index 0 in Build Settings or index 0 in the array you pass to BuildPlayer.
Q4: You can put a loader scene at build index 0 that checks Environment.GetCommandLineArgs and then loads one of the other scenes in the build.

Thanks a lot Adrian. That clears things up. Instead of creating a separate scene for each script, I was able to load the desired script based on command line args as you outlined. Here is the code for anyone who may want to do a similar thing.

using UnityEngine;

public class ScriptChooser: MonoBehaviour
{
    private Component m_component;

    protected virtual void Start()
    {
        Debug.Log("Starting ScriptChooser.");
        var args = System.Environment.GetCommandLineArgs();
        if (args.Length < 2)
        {
            Debug.Log("[ScriptChooser] Failed to start.  No script specified.");
            Application.Quit(-1);
            return;
        }

        string scriptName = args[1];

        GameObject camera = GameObject.Find("Main Camera");
        m_component = camera.AddComponent(System.Type.GetType(scriptName + ", AssemblyName"));
    }
}