Looking for a testing pattern/approach capable of handling different platforms/versions -


there 'code', being developed continuously. there testing server, server uses 'test code' test 'code' in different platforms. question involves 'test code'.

as said, server tests different platforms. happen, test code needs able handle different platforms. getting hard keep track of little 'differences' arise because of usage of different platforms. , gets more complicated, because platforms can have different versions and.. have test mixing of interchangeably.

right now, doing like:

test1()     if(platform == 'a' && version == '1.4')         assert('bla',bla)     else if(platform == 'a' && version == '1.5')         assert('ble',bla)     else if(version == '1.6')         assert('blu',bla)     ..... 

now, imagine 100x more complicated, , may see dealing right now. asking if out there knows pattern/approach handle more elegantly or robustly, if involves coding architecture support it.

thanks guys.

you can aggregate differences , lose if statements if store complexity within polymorphic objects. benefit can decouple platform differences testing code, after concerned making assertions different choices of environment.

here's simple example of mean, implemented in python. idea call test1 function once every environment configuration care about. details of should expect handled polymorphic objects. test code simple - mapping correct object, followed assertion.

#!/usr/bin/python  class platform_a(object):      def __init__(self, version):         self.version = version         self.bla_mapping = {                              '1.4' : 'bla',                              '1.5' : 'ble',                              '1.6' : 'blu'                             }          self.bla = self.bla_mapping[self.version]  # dummy stubs demo test code class platform_b(object):     def __init__(self):         # obviously, add platform b specific details here -         # example stub         self.bla = 'blu'  class platform_c(object):     def __init__(self):         # obviously, add platform c specific details here -         # example stub         self.bla = 'boo'  def get_the_platform(): return 'a' def get_the_version():  return '1.4' def result_of_running_the_real_code(): return 'bla'  def test1(platform, version):      # map platform names our polymorphic platform objects     env_mapping = dict(                         = platform_a,                         b = platform_b,                         c = platform_c,                                        )      # instantiate object corresponding unique environment under test     environment = env_mapping[platform](version)      # result of running real code in environment     bla = result_of_running_the_real_code()      # test got expected     assert(environment.bla, bla)   # test harness top level starts here # environment presumably specified test harness platform = get_the_platform() version  = get_the_version()  # run test test1(platform, version) 

Comments

Popular posts from this blog

apache - Add omitted ? to URLs -

redirect - bbPress Forum - rewrite to wwww.mysite prohibits login -

php - How can I stop spam on my custom forum/blog? -