Example #1
0
def create_unittest_css_rule(tag_id, css_rule_directory):
    '''
        Creates a parameterized css rule unit test method
    '''

    if len(css_rule_directory) == 0:
        return ''

    code = []
    code.append(create_tag_under_unittest_var_assignment(tag_id))
    code.append(JUNIT_ASSERT_EQUALS %('expectedValue',\
                                      SELENIUM_GET_CSS_VALUE %('tag', 'cssRuleName'),\
                                      '"wrong " + cssRuleName'))

    variable_dict = {
        'parameter_sources': create_csvsource_annotation(css_rule_directory),
        'what_is_tested': convert_tag_id_to_name_in_method(tag_id) + 'CssRule',
        'parameters': 'final String cssRuleName, final String expectedValue',
        'test_method_content': '\n\t'.join(code)
    }

    method = []
    method.append(JAVA_DOC_TEST_CSS_RULES % (tag_id))
    method.append(create_parameterized_unittest_method(variable_dict))

    return '\n'.join(method)
 def test_create_csvsource_annotation_many_param(self):
     expected = '@CsvSource({"key_1,value_1","key_2,value_2","key_3,value_3"})'
     parameter_dictionary = {
         'key_1': 'value_1',
         'key_2': 'value_2',
         'key_3': 'value_3'
     }
     actual = create_csvsource_annotation(parameter_dictionary)
     self.assertEqual(expected, actual)
Example #3
0
def __generate_unittest_attribute_code(tag_id, attribute_directory, code,
                                       java_doc):
    '''
    Generates the code for the attribute unit test.
    '''
    variable_dict = {
        'parameter_sources': create_csvsource_annotation(attribute_directory),
        'what_is_tested':
        convert_tag_id_to_name_in_method(tag_id) + 'Attributes',
        'parameters': 'final String attributeName, final String expectedValue',
        'test_method_content': '\n\t'.join(code)
    }

    method = []
    method.append(java_doc % (tag_id))
    method.append(create_parameterized_unittest_method(variable_dict))

    return '\n'.join(method)
 def test_create_csvsource_annotation_one_param(self):
     expected = '@CsvSource({"key_1,value_1"})'
     parameter_dictionary = {'key_1': 'value_1'}
     actual = create_csvsource_annotation(parameter_dictionary)
     self.assertEqual(expected, actual)
 def test_create_csvsource_annotation_no_param(self):
     expected = '@CsvSource()'
     parameter_dictionary = {}
     actual = create_csvsource_annotation(parameter_dictionary)
     self.assertEqual(expected, actual)