Odisseia 1.21.56
Português do BrasilManual oficial · 1.21.56
Sobre a tradução em inglês

TAssert.Eventually#

Repete uma função de condição até ela retornar True ou até o limite de tempo do executor de testes.

Assinatura#

procedure Eventually(const Condition: Callback; const TimeoutMilliseconds: Integer);

Exemplo#

uses
  odisseia.testing;

function ServicoDisponivel(Attempt: Integer): Boolean;
begin
  Result := Attempt >= 3
end;

var
  Assert: TAssert;

begin
  Assert := TAssert.Create;
  Assert.Eventually(ServicoDisponivel, 1000);
  WriteLn('condição atendida')
end.

Resultado esperado: condição atendida.

O callback possui a forma function(Attempt: Integer): Boolean. Se a condição não for satisfeita dentro do prazo, a asserção falha.

Pacote: odisseia.testing. Não exige permissões.