Z
Z
z00912014-07-01 19:34:48
Software testing
z0091, 2014-07-01 19:34:48

Test::Mojo - how to implement mojolicious app test grouping?

Hey!
I am writing tests for an application in mojolicious.

$t->post_ok($url->path('/login/authorize') => form => {password => 'cdcdcd'})
  ->status_is(200)
  ->content_type_is('application/json')
  ->json_is({ error => 1, result => 'bad validation' });

$t->post_ok($url->path('/login/authorize') => form => {password => ''})
  ->status_is(200)
  ->content_type_is('application/json')
  ->json_is({ error => 1, result => 'no param' });

my $tt = $t->post_ok($url->path('/login/authorize') => form => {password => $TEST_USER})
  ->status_is(200)
  ->content_type_is('application/json')
  ->json_has('/result/redirect')
  ->json_has('/result/token')
  ->json_is('/error' => 0 );

Interested in the question of how to implement tests in groups. In fact, there are 3 tests, but in reality it turns out 14.
ok 1 - POST http://localhost.tk:80/login/authorize?json=
ok 2 - 200 OK
ok 3 - Content-Type: application/json
ok 4 - exact match for JSON Pointer ""
ok 5 - POST http://localhost.tk:80/login/authorize?json=
ok 6 - 200 OK
ok 7 - Content-Type: application/json
ok 8 - exact match for JSON Pointer ""
ok 9 - POST http://localhost:80/login/authorize?json=
ok 10 - 200 OK
ok 11 - Content-Type: application/json
ok 12 - has value for JSON Pointer "/result/redirect"
ok 13 - has value for JSON Pointer "/result/token"
ok 14 - exact match for JSON Pointer "/error"
1..14

Thank you!

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question