API Testing
TestFly supports pure API tests and hybrid UI + API tests out of the box — same framework, same config, same report.
Pure API Tests — BaseApiTest
Extend BaseApiTest instead of BaseTest. No browser is launched; the full framework lifecycle still applies (reporting, @TestData, retry, CI gates).
import io.testfly.test.BaseApiTest;
import io.testfly.client.ApiClient;
import io.testfly.client.ApiResponse;
import org.testng.annotations.Test;
public class UserApiTest extends BaseApiTest {
@Test
public void getUserById() {
ApiResponse res = ApiClient.get("https://api.example.com/users/1")
.send();
res.assertStatus(200);
res.assertJson("$.name", "John Doe");
}
}