XMind2TestCase tool for efficiently designing test cases

1. Background:

In the software testing process, the most important and core thing is the design of test cases. It is also one of the tasks that the testing team and the testing team spend the most time on daily.

However, the traditional test case design process has many pain points:

  • 1. Using Excel tables for test case design is low-cost, but version management is troublesome, maintenance and updates are time-consuming, use case review is cumbersome, and process report statistics are difficult…
  • 2. Using traditional test management tools such as TestLink, TestCenter, and Redmine, although the execution, management, and statistics of test cases are more convenient, there are still problems such as low efficiency in writing use cases, insufficient divergence of ideas, and time-consuming in the process of rapid product iteration. …
  • 3. The company’s self-developed test management tools are a good choice, but for most small companies and small teams, on the one hand, R&D and maintenance costs are high, and on the other hand, there are certain requirements for technology…
  • 4….

Based on these circumstances, more and more companies are now choosing to use mind mapping, an efficient productivity tool, for use case design, especially agile development teams.

2. Environment installation

1. Install Python + Pycharm (everyone has installed it by default)

2. Install the xmind2testcase third-party library (-i domestic mirror source)

pip3 install xmind2testcase -i Simple Index

< h5 id=" The library

pip3 install -U xmind2testcase -i Simple Index

< h5 id=" cmd to open the command prompt window, enter: xmind2testcase webtool (the default port used is 5001) or xmind2testcase webtool 8888 (custom port)

5. Use http://192.168.31.204/:5001/ or http://localhost:5001/ to access the xmind2testcase website (written using the flask framework)

3. Selection of xmind tools and xmind test case rule template (installing xmind8 may require a system administrator account, please contact Huang Changyou to handle this;)

1. Selection of xmind tools (xmind-8-update9-windows)

Note that xmind2testcase only supports use cases written on xmind-8-update9-windows, so you must use the xmind-8-update9-windows tool to complete it;

If you don’t have the xmind-8-update9-windows installation package, click Baidu Netdisk to download it directly without installation;

3. Simple template example (xmind default template)

< h5 id=" Template parsing instance results (visit the xmind2testcase page, select the case xmind file I uploaded, and click to start conversion)

5. Simple template example, export CSV file

Note that we use the annotation Priority Icon as the boundary between “Test Title” and “Test Step”, if the parsing process does not encounter Priority Icon , then the subtopic chain behind TestSuite is used as a test case.

A test case supports only a title, without test steps and expected results, because during the actual testing process, we can often clarify the test points through the use case title.

6. Multi-level test template examples

Note: If there are preconditions at the hierarchical level, they will be automatically recognized and spliced together when parsing and generating use cases;

7 , Example display of multi-level use case template parsing results (Visit the xmind2testcase page, select the case xmind file I uploaded, and click Start Conversion)

8. Multi-level cases, export to csv

1. Modify the exported csv file Template title, set the use case template that matches the current test group, modify zentao.py

def xmind_to_zentao_csv_file(xmind_file):
       # before fixing
       # fileheader = ["Official module", "Use case title", "Precondition", "Step", "Expectation", "Keyword", "Priority", "Use case type", "Applicable stage"]
       # After modification
         fileheader = ["title", "description", "priority", 'step ID', "step", "expected result", "person in charge", "test case type", "requirements", "module", "Modified version", "Test case set"]

def gen_a_testcase_row(testcase_dict):
    #(You can comment out the original function, and then copy this code to the modified content)
    #Test case title
    case_title = testcase_dict['name']
    # Preconditions
    case_precontion = testcase_dict['preconditions']
    # priority
    case_priority = gen_case_priority(testcase_dict['importance'])
    # Step ID (set default value)
    case_stepId = 1
    # "Steps", "Expected results"
    case_step, case_expected_result = gen_case_step_and_expected_result(testcase_dict['steps'])
    # Handler (set default value)
    case_person = 'person in charge'
    #Test case type
    case_type = gen_case_type(testcase_dict['execution_type'])
    # Requirement ID
    case_storyId = gen_case_module(testcase_dict['suite'])
    # module
    case_module = 'Requirement module'
    # Fix version (set default value)
    case_version = 'version'
    # Test case set (set default value)
    case_suites = '[Requirement module] version function use case set'
    row = [case_title, case_precontion, case_priority, case_stepId, case_step, case_expected_result, case_person, case_type, case_storyId, case_module, case_version, case_suites]
    return row
2. Modify the test case priority, modify zentao.py
def gen_case_priority(priority):
    # before fixing
    # mapping = {1: 'High', 2: 'Medium', 3: 'Low'}
    # After modification
    mapping = {1: 'High', 2: 'Medium', 3: 'Low'}
    if priority in mapping.keys():
        return mapping[priority]
    else:
        # before fixing
        # return '中'
        # After modification
        return 'Medium'
3. Modify the test case type, modify zentao.py
def gen_case_type(case_type):
    # before fixing
    # mapping = {1: 'manual', 2: 'automatic'}
    # After modification
    mapping = {1: 'Functional test case', 2: 'Compatibility test case', 3: 'Security test case', 4: 'Performance test case', 5: 'Usability test case', 6: 'Others Type use case'}
    if case_type in mapping.keys():
        return mapping[case_type]
    else:
        # before fixing
        # return 'manual'
        # After modification
        return 'Functional test case'
4. Modify again Test types of other files, so that they correspond to the third zentao file one-to-one, modify parser.py
Before modification:

def get_execution_type(topics):
    labels = [topic.get('label', '') for topic in topics]
    labels = filter_empty_or_ignore_element(labels)
    exe_type = 1
    for item in labels[::-1]:
        if item.lower() in ['automatic', 'auto', 'automate', 'automation']:
            exe_type = 2
            break
        if item.lower() in ['manual', 'manual', 'manual']:
            exe_type = 1
            break
    return exe_type
After modification:

def get_execution_type(topics):
    labels = [topic.get('label', '') for topic in topics]
    labels = filter_empty_or_ignore_element(labels)
    exe_type = 1
    for item in labels[::-1]:
        if item.lower() in ['compatibility', 'compatibility', 'compatibility test case']:
            exe_type = 2
            break
        if item.lower() in ['security', 'security test case']:
            exe_type = 3
            break
        if item.lower() in ['Performance', 'Performance test case']:
            exe_type = 4
            break
        if item.lower() in ['ease of use', 'ease of use', 'usability test case']:
            exe_type = 5
            break
        if item.lower() in ['other', 'other']:
            exe_type = 6
            break
        if item.lower() in ['manual', 'manual', 'function']:
            exe_type = 1
            break
    return exe_type
5. There are blank lines in the export file, modify zentao.py

Find the xmind_to_zentao_csv_file function in the zentao.py file, and add newline=” to the file writing method

Before modification:

with open(zentao_file, 'w', encoding='utf8') as f:
After modification:

with open(zentao_file, 'w', encoding='utf8', newline='') as f:
6. Use case steps , add one space after the expected result serial number, modify zentao.py (see if you need to modify it)
def gen_case_step_and_expected_result(steps):
    case_step = ''
    case_expected_result = ''
    # After modification, remove the space after + '. ' + + '.' +
    for step_dict in steps:
        case_step + = str(step_dict['step_number']) + '. ' + step_dict['actions'].replace('\
', '').strip() + '\
'
        case_expected_result + = str(step_dict['step_number']) + '. ' + \
            step_dict['expectedresults'].replace('\
', '').strip() + '\
' \
            if step_dict.get('expectedresults', '') else ''
7. Each exported use case step and expected results There will be one more newline character, modify zentao.py
def gen_case_step_and_expected_result(steps):
    case_step = ''
    case_expected_result = ''
    for step_dict in steps:
        .....(can be added later)
    # Add and remove the last newline character in each cell
    case_step = case_step.rstrip('\
')
    case_expected_result = case_expected_result.rstrip('\
')
    return case_step, case_expected_result
8. If In the case of multi-layer use case design, we can add [-] to the use case title and modify parser.py
def gen_testcase_title(topics):
    """Link all topic's title as testcase title"""
    titles = [topic['title'] for topic in topics]
    titles = filter_empty_or_ignore_element(titles)

    # when separator is not blank, will add space around separator, e.g. '/' will be changed to ' / '
    separator = config['sep']
    if separator != ' ':
        # The original format is {}, then modify it to -{}
        separator = ' -{} '.format(separator)

< h5 id=" , Since we import jira to detect it through the requirement ID, we need to use regular expressions to match the requirement number and modify utils.py

utils.py file, find the get_xmind_testcase_list function, findcase_data[‘suite’] = suite.name, comment it out first, and then copy the following code
# case_data['suite'] = suite.name
# After modification
import re
# Define the matching regular expression pattern
pattern = r'\[(.*?)\]'
# Use the re.search() method to find the first matching substring
matches = re.search(pattern, suite.name)
# Output matching results
if matches:
    case_data['suite'] = matches.group(1)
else:
    pass

5. Actual scenario case operations;

1. xmind actually writes cases;

2. The case analysis results are as follows;

3. Export csv test cases;

Be sure to replace the person in charge, modify the version, and test the test case set;

Be sure to replace the person in charge, modify the version, and test the test case set;

Be sure to replace the person in charge, modify the version, and test the test case set;

In addition, you can use a shortcut key to quickly prioritize use cases, such as The priority is medium. After batch selection, just press ctrl + 2 (1: High priority , 2: medium priority, 3: low priority)

Finally, modify the encoding format of this csv file to utf-8, and then import it into jira;

6. FAQ

1. The conversion case failed, prompting “The file cannot be opened normally, please do not modify and save, otherwise the file content will be permanently lost!”

Answer: The version of xmind used does not match. Just use xmind 8 to open the file and save it.

2. In the converted use case, the step content is in the testcase section, but the steps are empty?

Answer: xmind2testcase uses the priority icon as the boundary between “test title” and “test step”. If the priority icon is not encountered during the parsing process, the subtopic chain behind TestSuite is used as a test case. A test case supports only a title, without test steps and expected results, because during the actual testing process, we can often clarify the test points through the use case title.