orleanz: (main)
[personal profile] orleanz
Во, нашел совет на СО

The best way to test a private method is via another public method.
If this cannot be done, then one of the following conditions is true:

1 The private method is dead code

2 There is a design smell near the class that you are testing

3 The method that you are trying to test should not be private

http://stackoverflow.com/questions/34571/how-to-test-a-class-that-has-private-methods-fields-or-inner-classes

Date: 2016-05-19 02:53 pm (UTC)
From: [identity profile] juan-gandhi.livejournal.com
О, точно, я просто рисовал метод с навзанием ..._for_testing

Date: 2016-05-19 04:44 pm (UTC)
From: [identity profile] sab123.livejournal.com
Типовой подход - никогда не использовать слово private. Использовать только protected. После чего делается подкласс, которые вызывает защищенные методы.

Date: 2016-05-20 09:10 am (UTC)
From: [identity profile] trailmax.livejournal.com
А полгода спустя когда захочется сделать рефакторинг, огрести ведро упавших тестов, хотя корректность выполняемых действий не изменилась.

Date: 2016-05-20 05:48 pm (UTC)
From: [identity profile] sab123.livejournal.com
Ась? Когда будет рефакторинг кода, тогда и рефакторинг внутренних тестов. Просто надо различать слои тестов. Самыми главными, конечно, являются тесты end-to-end, продукта целиком, но их же и тяжелее всего сделать подробными. А более низкоуровневые тесты пишутся только если снаружи протестировать фичу невозможно или очень медленно.

Profile

orleanz: (Default)
orleanz

December 2018

S M T W T F S
      1
2345678
9101112 131415
16171819202122
23242526272829
3031     

Most Popular Tags

Style Credit

Expand Cut Tags

No cut tags
Page generated Jun. 26th, 2025 01:57 am
Powered by Dreamwidth Studios