<output id="qn6qe"></output>

    1. <output id="qn6qe"><tt id="qn6qe"></tt></output>
    2. <strike id="qn6qe"></strike>

      亚洲 日本 欧洲 欧美 视频,日韩中文字幕有码av,一本一道av中文字幕无码,国产线播放免费人成视频播放,人妻少妇偷人无码视频,日夜啪啪一区二区三区,国产尤物精品自在拍视频首页,久热这里只有精品12

      將 XMind 測(cè)試用例轉(zhuǎn)換為 CSV 文件導(dǎo)入測(cè)試管理平臺(tái)

      在日常的軟件測(cè)試工作中,我們常常使用 XMind 來(lái)整理測(cè)試用例。XMind 的可視化結(jié)構(gòu)讓用例層次清晰、邏輯直觀,但當(dāng)我們需要將這些用例導(dǎo)入到測(cè)試管理平臺(tái)(如 TestRail、禪道、Jira 等)時(shí),就需要把它們轉(zhuǎn)換成 CSV 文件。本文就分享一個(gè)簡(jiǎn)單易行的方法。


      為什么需要轉(zhuǎn)換

      1. 批量導(dǎo)入:測(cè)試管理平臺(tái)通常支持 CSV 批量導(dǎo)入,避免重復(fù)手動(dòng)錄入。
      2. 結(jié)構(gòu)清晰:XMind 中的測(cè)試用例按模塊、功能、子功能組織,轉(zhuǎn)換成 CSV 后便于統(tǒng)一管理。
      3. 提高效率:特別是面對(duì)上百條用例時(shí),自動(dòng)化轉(zhuǎn)換節(jié)省大量時(shí)間。

      說(shuō)明

      這里我用到的xminf版本是圖中這個(gè),其他版本自測(cè)
      image

      準(zhǔn)備工作

      • XMind 文件:確保你的測(cè)試用例已經(jīng)整理好,最好按照模塊-功能-用例步驟的層級(jí)結(jié)構(gòu)。

      操作步驟

      1. XMind文件格式

      目前腳本按這個(gè)格式處理的,可以根據(jù)自己的需求部分代碼
      image

      2. 編寫(xiě)轉(zhuǎn)換腳本

      用 Java 可以快速把文本解析成 CSV,例如:

      import com.fasterxml.jackson.databind.JsonNode;
      import com.fasterxml.jackson.databind.ObjectMapper;
      import com.opencsv.CSVWriter;
      import java.io.FileNotFoundException;
      import java.io.FileWriter;
      import java.io.IOException;
      import java.io.InputStream;
      import java.nio.file.Path;
      import java.nio.file.Paths;
      import java.util.ArrayList;
      import java.util.Enumeration;
      import java.util.List;
      import java.util.Scanner;
      import java.util.concurrent.atomic.AtomicReference;
      import java.util.zip.ZipEntry;
      import java.util.zip.ZipFile;
      
      
      public class XmindToCsvConverter {
          public static void main(String[] args) throws Exception {
              // XMind 文件路徑
              String xmindFile = "/Users/xx.xmind";
              convertXmindToCsv(xmindFile);
          }
      
          public static void convertXmindToCsv(String xmindFile) throws Exception {
              // 1. 解壓 XMind 并讀取 content.json
              String jsonContent = extractJsonFromXmind(xmindFile);
              ObjectMapper objectMapper = new ObjectMapper();
              JsonNode rootNode = objectMapper.readTree(jsonContent);
      
              // 獲取根節(jié)點(diǎn)的名稱(chēng),作為 CSV 文件名
              String rootTitle = rootNode.get(0).get("rootTopic").get("title").asText();
      
              // 確定 CSV 文件路徑(與 XMind 文件同目錄)
              Path xmindPath = Paths.get(xmindFile);
              // 獲取 XMind 所在目錄
              String outputDir = xmindPath.getParent().toString();
              // 生成 CSV 文件路徑
              String outputCsv = outputDir + "/用例csv/" + rootTitle + ".csv";
      
              System.out.println("CSV文件名: " + outputCsv);
      
              // 2. 解析 JSON 生成測(cè)試用例
              List<String[]> testCases = new ArrayList<>();
              // CSV 表頭
              testCases.add(new String[]{"模塊", "用例標(biāo)題", "前置條件", "步驟ID", "步驟", "預(yù)期結(jié)果"});
      
              // 變量存儲(chǔ)上一個(gè)節(jié)點(diǎn)信息
              AtomicReference<String> lastModule = new AtomicReference<>("");
              AtomicReference<String> lastCaseTitle = new AtomicReference<>("");
              AtomicReference<String> lastPrecondition = new AtomicReference<>("");
              AtomicReference<Boolean> isFirstStep = new AtomicReference<>(true);
      
              // 遍歷 XMind 結(jié)構(gòu)
              for (JsonNode sheet : rootNode) {
                  traverseNode(sheet.get("rootTopic"), new ArrayList<>(), testCases, lastModule, lastCaseTitle, lastPrecondition, isFirstStep);
              }
      
              // 3. 保存到 CSV 文件
              try (CSVWriter writer = new CSVWriter(new FileWriter(outputCsv))) {
                  writer.writeAll(testCases);
              }
      
              System.out.println("轉(zhuǎn)換完成: " + outputCsv);
          }
      
          private static String extractJsonFromXmind(String xmindFile) throws IOException {
              try (ZipFile zipFile = new ZipFile(xmindFile)) {
                  for (Enumeration<? extends ZipEntry> entries = zipFile.entries(); entries.hasMoreElements(); ) {
                      ZipEntry entry = entries.nextElement();
                      if (entry.getName().endsWith("content.json")) {
                          try (InputStream is = zipFile.getInputStream(entry);
                               Scanner scanner = new Scanner(is, "UTF-8")) {
                              return scanner.useDelimiter("\\A").next();
                          }
                      }
                  }
              }
              throw new FileNotFoundException("content.json not found in XMind file");
          }
      
          private static void traverseNode(JsonNode node, List<String> path, List<String[]> testCases, AtomicReference<String> lastModule, AtomicReference<String> lastCaseTitle, AtomicReference<String> lastPrecondition, AtomicReference<Boolean> isFirstStep) {
              if (node == null || !node.has("title")) return;
              List<String> newPath = new ArrayList<>(path);
              newPath.add(node.get("title").asText());
              if (node.has("children")) {
                  for (JsonNode child : node.get("children").get("attached")) {
                      traverseNode(child, newPath, testCases, lastModule, lastCaseTitle, lastPrecondition, isFirstStep);
                  }
              } else {
                  int size = newPath.size();
                  String module = size >= 3 ? String.join("-", newPath.subList(0, 3)) : "";
                  String caseTitle = size >= 4 ? newPath.get(3) : "";
                  boolean hasPrecondition = (size == 8);
                  String precondition = hasPrecondition ? newPath.get(4) : "";
                  String stepId = hasPrecondition ? newPath.get(5) : (size >= 5 ? newPath.get(4) : "");
                  String step = hasPrecondition ? newPath.get(6) : (size >= 6 ? newPath.get(5) : "");
                  String expectedResult = hasPrecondition ? newPath.get(7) : (size >= 7 ? newPath.get(6) : "");
      
                  // 用例的第一步保留模塊名稱(chēng)
                  if (caseTitle.equals(lastCaseTitle.get())) {
                      caseTitle = "";
                      precondition = "";
                      if (!isFirstStep.get()) {
                          module = "";
                      }
                  } else {
                      lastCaseTitle.set(caseTitle);
                      lastPrecondition.set(precondition);
                      // 新用例的第一步
                      isFirstStep.set(true);
                  }
      
                  testCases.add(new String[]{module, caseTitle, precondition, stepId, step, expectedResult});
                  // 之后的步驟不再顯示模塊
                  isFirstStep.set(false);
              }
          }
      }
      

      提示:根據(jù)實(shí)際導(dǎo)出的文本格式,可能需要調(diào)整解析邏輯。

      3. 導(dǎo)入到測(cè)試管理平臺(tái)

      • 打開(kāi)平臺(tái)的導(dǎo)入功能 → 選擇 CSV 文件 → 映射字段 → 批量導(dǎo)入。
      • 導(dǎo)入完成后,檢查用例層級(jí)和步驟是否正確。

      總結(jié)

      將 XMind 測(cè)試用例轉(zhuǎn)換為 CSV 文件并導(dǎo)入測(cè)試平臺(tái),雖然看似多了一步,但合理利用腳本工具和平臺(tái)導(dǎo)入功能,可以極大提升效率,減少重復(fù)勞動(dòng)。對(duì)于日常測(cè)試工作來(lái)說(shuō),這是一項(xiàng)值得掌握的小技巧。

      posted @ 2025-10-18 17:36  季沐測(cè)試筆記  閱讀(16)  評(píng)論(0)    收藏  舉報(bào)
      主站蜘蛛池模板: 亚洲综合久久一区二区三区| 日韩精品久久久肉伦网站| 四虎国产精品永久在线| 国产普通话对白刺激| 国产偷窥熟女高潮精品视频| 国产激情艳情在线看视频| 精品国产迷系列在线观看| 天干天干夜啦天干天干国产| 尹人香蕉久久99天天拍欧美p7 | 国产a在视频线精品视频下载| 成人性做爰aaa片免费看| 亚洲天天堂天堂激情性色| 周口市| 美欧日韩一区二区三区视频 | 久久亚洲中文无码咪咪爱| 中文无码av一区二区三区| 91午夜福利在线观看精品| 日本熟妇色xxxxx| 欧美成本人视频免费播放| 亚洲熟妇丰满多毛xxxx| 色伦专区97中文字幕| 亚洲综合伊人久久大杳蕉| 欧美乱大交xxxxx疯狂俱乐部| 91精品亚洲一区二区三区| 无码日韩做暖暖大全免费不卡| 久久大香线蕉国产精品免费| 日韩黄色av一区二区三区| 久久久精品94久久精品| 泸水县| 亚洲av日韩在线资源| 九九热精品免费视频| 国产日韩另类综合11页| 最新午夜男女福利片视频| 黑人大战中国av女叫惨了| 国产日韩一区二区在线看| 无码专区 人妻系列 在线| 激情97综合亚洲色婷婷五| 日本欧洲亚洲高清在线| 少妇久久久被弄到高潮| 亚洲av乱码一区二区| 美女自卫慰黄网站|