Skip to content

Conversation

tuanvh-0174
Copy link

Purpose/Notes

Screenshot

Screenshot from 2021-05-24 00-29-21

Checklist (*)

  • Pull request has been self-reviewed
  • Pull request has a meaningful description of its purpose
  • All commits are accompanied by meaningful commit messages
  • All CI builds passed successfully (all builds are green)

@tuanvh-0174 tuanvh-0174 force-pushed the vu.huy.tuan_unittest branch from 4beb3f7 to aa76722 Compare May 24, 2021 08:21
$this->assertEquals($class, $expectValue);
}

public function provideData()

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Anh ơi với bài này thì em nghĩ nên tách mỗi case ra một hàm để còn xem là với trường hợp ngày lễ có đúng màu đỏ, với ngày cn có đúng màu đỏ, .v.v. Ý là cho meaning hơn ấy ạ.
Với anh thiếu case ngày thường color là BLACK ạ

Copy link
Author

@tuanvh-0174 tuanvh-0174 Jun 21, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  • trong provideData có $expectValue rồi, a nghĩ cũng k cần thiết phải tách ra nhiều func đâu
  • case: color Black a update rồi nhé

$this->controller = new Exercise05Controller($this->mockOrderService);
}

public function testIndex()

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

https://sun-unit-test-training.github.io/php-testing-guideline/06-checklist/#1-self-describing-test-method

Tên function nên thể hiện được a test case nào và expect của test case của test case a nhé

Copy link
Author

@tuanvh-0174 tuanvh-0174 Jun 21, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

a thấy k cần thiết sửa đâu, ở đây mình đang test theo file, theo method mà,
Sau muốn update file test, vào file test mình thấy rõ hơn đang đã viết test cho những method nào rồi

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Việc đặt tên nó khá quan trọng ạ . Đây là case đơn giản thì mình có thể viết ngẵn gọn được
Nhưng với nhiều case phức tạp thì cách đặt tên nó sẽ giúp bản thân mình đọc code dễ dàng hơn
trong case này e thấy tên ntn là hợp lý ạ

test_index_return_view_success

public function testHandleDiscount($detailOrder, $expectValue)
{
$response = $this->orderService->handleDiscount($detailOrder);
//print_r($response);

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

code ko cần thiết thì xóa đi a nhé

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants