首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >REST上的非回归测试工具?

REST上的非回归测试工具?
EN

Stack Overflow用户
提问于 2022-10-07 17:35:46
回答 1查看 22关注 0票数 0

我开发了一个以symfony服务器为后端,以移动应用程序为前端的项目。

我失业了,但我希望自己创业:)

我应该使用什么工具进行非回归测试?

谢谢你的帮助!

EN

回答 1

Stack Overflow用户

发布于 2022-10-08 15:15:14

我想您不使用API平台。它提供了提供几个断言来测试JSON响应的ApiTestCase

代码语言:javascript
复制
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手动完成此操作。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/73990741

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档