geberit / Revit.TestRunner

Unit Test Runner for Autodesk Revit
MIT License
83 stars 30 forks source link

Service may not be running... #16

Closed ricaun closed 2 years ago

ricaun commented 2 years ago

I had this strange problem...

Sometimes when I execute Revit.TestRunner.Console.exe to make some tests. I receive the message: Tests not executed! Service may not be running. Everything is installed correctly, sometimes works fine others I receive this message...

Revit TestRunner Error

I don't know what could be wrong, maybe my computer is slow or Revit does not have time to finish the addin initialization.

Any idea?

tobiasfloescher-geberit commented 2 years ago

Hi. Sometimes I have a similar issue with the App. Not sure if it is the same. The App says 'no test executed', but Revit runs the test, just the response is missing. Till now I'm not sure what this causes. Probably a communication-timing failure. I will try to reproduce and make some adjustments.

ricaun commented 2 years ago

In my case only happens when the Console starts Revit, probably a delayed show work.

I don't know how the communication between the Revit and the Revit.TestRunner works.

I noted is not possible to run 2 Revit at the same time. 😢

tobiasfloescher-geberit commented 2 years ago

Needs some investigation. Multiple Revits are not supported at the moment, but I will take this in the backlog.

ricaun commented 2 years ago

@tobiasfloescher-geberit could you help me to understand how the communication between Revit and the Revit.TestRunner.Console works?

By looking at the code, RunnerController basically run an idling event and check some folders using the FileServer to find some .request files.

I supposed that's how works on the Revit side...

tobiasfloescher-geberit commented 2 years ago

Correct, the FileServer looks for some .request files in the specified route (subfolder) and run the Route. This is triggered by the OnIdle event of Revit. Except the HomeRoute (concurrent), this runs in a seperate Task.

The FileClient is the counter part. GetJson calls a http like 'Get' by writing the .request file to the specified route folder and waits for the .response file in this folder, written by the Server.

The files are serialized jsons.

ricaun commented 2 years ago

Nice! I gonna try to make some tests related to the Service may not be running.

About Revit multi-version, probably a specified route (subfolder) with the Revit version should separate the .request files for each Revit version. 😊

ricaun commented 2 years ago

I kinda fix the issue by adding a delay to wait for the resultFile.

// Wait resultFile 
for (int i = 0; i < 10; i++)
    if (!File.Exists(resultFile))
    {
        Console.WriteLine($"."); // Wait resultFile
        await Task.Delay(200, cancellationToken);
    }

And found some problem with revit.IsNew not killing Revit.

And add some cmd files on the Revit.TestRunner.SampleTestProject2 to make easy to test using the Revit.TestRunner.Console.exe.

Gonna create a PR tomorrow: https://github.com/ricaun/Revit.TestRunner