How to terminate unit tests run correctly

Discussion created by pmasson on Oct 16, 2020
Latest reply on Oct 23, 2020 by pmasson



I have a bunch of unit tests (MSTest) using ArcGis Pro SDK. 


All my tests run well except that when the test run is done, the testhost.exe process stay alive. That prevents the unit test task in TFS (Azure) to complete. It's stay there for 45 minutes before TFS stopping it. If I go on the server and kill the testhost.exe process, the MSTest task terminate correctly.


I think it's related to QueuedTasks used to run the test. I have other tests that don't use queuedTask and the testhost.exe process shuts down after test completion.


I've tried everything and I can reproduce the behavior easily with this simple sample.


Can you help please? What is the correct way to do it?


public class Test_entity
    public static void ClassInitialize(TestContext context)

    PipeService _entityService;
    public override IEntityService<Pipe> entityService
            if(_entityService == null)
                _entityService = new PipeService();
            return _entityService;

    public TestContext TestContext { get; set; }


    public IEntityService<Pipe> entityService { get; }


    [DeploymentItem("unitsData", "unitsData")]
    public void TestGetByObjectId()

        Pipe entity = null;
        Task t = QueuedTask.Run(() =>
            entity = entityService.getByObjectId(1);


        Assert.IsTrue(entity != null));