UnitTestDetail.vue 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125
  1. <template>
  2. <div>
  3. <page-header
  4. :loading="testDetailLoading"
  5. :routes="[
  6. { name: '代码作业', path: 'code' },
  7. { name: '项目列表', path: `code/${$route.params.homeworkId}` },
  8. {
  9. name: '项目详情',
  10. path: `code/${$route.params.homeworkId}/${
  11. $route.params.projectId
  12. }/test`
  13. },
  14. { name: '单元测试' }
  15. ]"
  16. >
  17. <template slot="title">
  18. 单元测试 #{{ testDetail.id }}
  19. </template>
  20. <template slot="content">
  21. <pass-tag v-if="testDetail.status == 1" :pass="testDetail.passAll" />
  22. <b-tag v-else type="is-warning">RUNNING</b-tag>
  23. </template>
  24. <template slot="extraContent">
  25. <div class="tag">{{ displayUnixTime(testDetail.time) }}</div>
  26. </template>
  27. </page-header>
  28. <!--<div class="console-section">{{ testDetail.consoleOutput }}</div>-->
  29. <page-body>
  30. <div v-if="testDetailLoading"><page-section-loading show /></div>
  31. <div v-else>
  32. <div class="gap-section">
  33. <div class="page-section">
  34. <a class="button is-small is-info" @click="showLog = !showLog">{{
  35. showLog ? "收起控制台信息" : "查看控制台输出"
  36. }}</a>
  37. <div class="console-section" v-if="showLog">
  38. {{ testDetail.consoleOutput }}
  39. </div>
  40. </div>
  41. </div>
  42. <div
  43. v-for="item in testDetail.detail"
  44. :key="item.id"
  45. class="gap-section"
  46. >
  47. <div class="page-section">
  48. <div>
  49. <pass-tag :pass="item.pass" />
  50. <strong style="padding-left: 10px">
  51. 单元测试用例 : #{{ item.id }}
  52. </strong>
  53. </div>
  54. <div v-if="!item.pass" class="code-section">
  55. {{ item.message }} <br />
  56. <br />
  57. {{ item.trace }}
  58. </div>
  59. </div>
  60. </div>
  61. </div>
  62. </page-body>
  63. </div>
  64. </template>
  65. <script>
  66. import PageHeader from "@/components/PageHeader";
  67. import PageBody from "@/components/PageBody/index";
  68. import { getUnitTestDetail } from "@/api/codehw";
  69. import timeMixins from "@/mixins/time";
  70. import PassTag from "@/views/student/Code/ProjectDetail/components/PassTag";
  71. import PageSectionLoading from "@/components/PageBody/PageSectionLoading/index";
  72. import BTag from "buefy/src/components/tag/Tag";
  73. export default {
  74. components: {
  75. BTag,
  76. PageSectionLoading,
  77. PassTag,
  78. PageBody,
  79. PageHeader
  80. },
  81. data() {
  82. return {
  83. testDetail: { detail: [] },
  84. testDetailLoading: false,
  85. showLog: false
  86. };
  87. },
  88. mixins: [timeMixins],
  89. mounted() {
  90. const { unitTestId } = this.$route.params;
  91. this.testDetailLoading = true;
  92. getUnitTestDetail(unitTestId).then(value => {
  93. this.testDetail = value.data;
  94. this.testDetailLoading = false;
  95. });
  96. }
  97. };
  98. </script>
  99. <style lang="scss" scoped>
  100. @import "../../../../../assets/scss/app";
  101. .gap-section {
  102. padding-bottom: $default-margin-between;
  103. }
  104. .gap-section:last-child {
  105. padding-bottom: 0;
  106. }
  107. .code-section {
  108. margin: $default-margin-between -#{$default-margin-between} -#{$default-margin-between};
  109. padding: $default-margin-between;
  110. background-color: #2d3044;
  111. color: #cacff1;
  112. white-space: pre-line;
  113. }
  114. .console-section {
  115. padding: $default-margin-between $default-margin-between * 1.5;
  116. background-color: #2d3044;
  117. color: #cacff1;
  118. white-space: pre-line;
  119. }
  120. </style>