我开发了一个以symfony服务器为后端,以移动应用程序为前端的项目。
我失业了,但我希望自己创业:)
我应该使用什么工具进行非回归测试?
谢谢你的帮助!
发布于 2022-10-08 15:15:14
我想您不使用API平台。它提供了提供几个断言来测试JSON响应的ApiTestCase:
class BooksTest extends ApiTestCase
{
// This trait provided by AliceBundle will take care of refreshing the database content to a known state before each test
use RefreshDatabaseTrait;
public function testGetCollection(): void
{
// The client implements Symfony HttpClient's `HttpClientInterface`, and the response `ResponseInterface`
$response = static::createClient()->request('GET', '/books');
$this->assertResponseIsSuccessful();
// Asserts that the returned content type is JSON-LD (the default)
$this->assertResponseHeaderSame('content-type', 'application/ld+json; charset=utf-8');
// Asserts that the returned JSON is a superset of this one
$this->assertJsonContains([
'@context' => '/contexts/Book',
'@id' => '/books',
'@type' => 'hydra:Collection',
'hydra:totalItems' => 100,
'hydra:view' => [
'@id' => '/books?page=1',
'@type' => 'hydra:PartialCollectionView',
'hydra:first' => '/books?page=1',
'hydra:last' => '/books?page=4',
'hydra:next' => '/books?page=2',
],
]);如您所见,在本例中,将测试API的/books端点。但您也可以使用Symfony提供的标准WebTestCase手动完成此操作。
https://stackoverflow.com/questions/73990741
复制相似问题