I need a local HTTP server for my unit test.
When I try to activate TIdHTTPServer at SetUp, it fails with EThread message:
“Thread Error: descriptor not valid (6)”
This is how I initialize it:
type
TestMyUnit = class(TTestCase)
...
procedure TestMyUnit.SetUp;
begin
FServer := TIdHTTPServer.Create(nil);
FServer.OnCommandGet := HTTPServerCommandGet;
FServer.Active := True; // <---- This will cause error
end;
Maybe there are some restrictions using Indy’s TIdHTTPServer with DUnit framework?
- Delphi 2010
- Indy 10
Exception was thrown somewhere after this line in TIdListenerThread.Run proc (IdCustomTCPServer unit)
LIOHandler := Server.IOHandler.Accept(Binding, Self, LYarn);
However, I can’t trace it deeper, I don’t know why.
Solved. I have my own DPK with self-designed components (used by this unit-test), and there was 1 unit with references to Indy. After I have rebuild that package, the compiler proposed me to add some new DCCReference to Indy components. After I reinstalled my package, that error in unit-test has gone.
I can’t imagine the cause-and-effect relations, but now it’s ok.