I'm creating unittests to a payment process. There is about 20 unit unittests to write -some positives cases and some negatives.
example:
payment_screen=PaymentScreen()
and there I few conceptions.
First - create a Payer object with giving attributes:
payer=Payer(last_name,country_code)
country_code is important, because system doesn't allow to sending items to other countries
Second
payer=Payer.return_correct_payer()
something like:
class Payer:
@staticmethod
def return_correct_payer():
payer=Payer()
payer.country_code='US'
payer.last_name='Smith'
and in both options
payment_screen.fill_payer_data(payer)
And an another conception:
in payment_screen just create two methods:
fill_payer_data_with_correct_data()
and
fill_payer_data_with_uncorrect_data()
Which one is the best? Or maybe you have another idea(I'm sure that you have)
EDIT
Thanks for your replies, but it's not what I need. I just don't want create object Pax in every test case with giving attributes.
I have 20 test cases so now I must write 20 times :
payer=Payer('Smith','US')
I don't want duplicate my code