Multithread support

Issue #137 closed
wlandgraf created an issue

I wonder, if TestInsight client will work fine is the unit test framework (e.g., a modified DUnit) run the tests in parallel? Will it listen and display results accordingly?

Comments (5)

  1. Stefan Glienke repo owner

    I cannot say this is something I considered when writing it - but the client sources are all available to you, so you are welcome to check them for any multithreading issue.

    Quick look through TestInsight.DUnit and TestInsight.Client:

    • fLastError may be written from multiple threads - iirc this was to avoid overwriting an error with a success - changing this to threadvar might solve a potential race as in such a case the false AddSuccess would be from the same thread than the previous error
    • by default test results are added to the fTestResults list in the client and only sent in one batch when finished (faster, thats the blue circle arrow button in the IDE plugin) - that would not be threadsafe - so either putting a lock there or storing results in lists for each thread and then combine them at the end and send.
    • fRequest is created once and then its Text set in the Post method - that clearly would not work in multithread - but: it’s only called once at the start, and at the end if you don’t use the “show progress by sending each result individually” option.

  2. wlandgraf reporter

    Thanks for insightful info @Stefan Glienke . But I used the wrong terms. By client I was referring to the plugin, which I don’t have the source code I guess.

    Yes, I can modify the existing units, but once they are done, they will send info to the plugin in non predictable order. My question is, will the plugin handle it accordingly, showing me correct results?

  3. Stefan Glienke repo owner

    Since it’s all done through one TIdHTTP instance there won’t be any parallelism in the plugin - after all its just a TIdHTTPServer sitting there - well if you would have dozens of test projects running all trying to report to one IDE now that could potentially go wrong.

    The order of the results in the list sent to the IDE does not matter.

  4. wlandgraf reporter

    Thank you. Yes, there won’t be a gazillion of simultaneous tests, but a few might come in parallel. I will give it a try and let you know.

  5. Log in to comment