Dolphinscheduler: [Test][api] Improvement `TaskInstanceServiceTest`

Created on 19 Aug 2020  ·  8Comments  ·  Source: apache/dolphinscheduler

Describe the question
Improvement the TaskInstanceServiceTest test case for TaskInstanceService for full coverage (100% method coverage).

Test case example
https://github.com/apache/incubator-dolphinscheduler/blob/dev/dolphinscheduler-api/src/test/java/org/apache/dolphinscheduler/api/service/ProcessDefinitionServiceTest.java

Test case specifications
https://dolphinscheduler.apache.org/zh-cn/docs/development/unit-test.html
Important: Need to improvement the test case according to the specifications

Which version of DolphinScheduler:
-[dev]

Most helpful comment

..... 英文不好的我哭出声, 翻译后, 结果被人抢先了

All 8 comments

Anyone who want to take it, welcome to leave a message~

Anyone who want to take it, welcome to leave a message~

I will take [Test-3556] to write the unittest to full coverage.

I will be willing to do this. Before i am doing this, I want you to confirm the unit test cases I need to write.

截屏2020-08-20 21 00 08

I use the following test case to cover the yellow(current unit test case not all hit) and red(current unit test case not hit) lines:

  1. param without stateType
  2. param without startDate
  3. param without endDate
  4. param startDate with illegal format
  5. param startDate with illegal format
  6. both 4 and 5

May be i can use only one unit test case to cover this, I'm not sure which one is better.

Finally I have a question, Why put so many unit test cases into one method? As i am concerned, i'd like to place each unit test in one method., then named the method with "given_xxx_when_xxx_then_xxx" or comment with "given xxx when xxx then xxx". When [regression testing | CI] running fail, i can locate cause of unit test case instead of method name.

I just remove the try catch, no need to catch ,
the parse will return null rather than throw exception

    /**
     * convert string to date and time
     *
     * @param date date
     * @param format format
     * @return date
     */
    public static Date parse(String date, String format) {
        try {
            LocalDateTime ldt = LocalDateTime.parse(date, DateTimeFormatter.ofPattern(format));
            return localDateTime2Date(ldt);
        } catch (Exception e) {
            logger.error("error while parse date:" + date, e);
        }
        return null;
    }

..... 英文不好的我哭出声, 翻译后, 结果被人抢先了

..... 英文不好的我哭出声, 翻译后, 结果被人抢先了

Currently, our server module has some unit tests that need to be refactored, maybe you can try to participate in this

3512

You can refer to our unit test benchmarks, we will present a case, and hope that you can participate together

..... 英文不好的我哭出声, 翻译后, 结果被人抢先了

Hi, i am sorry for that, but you can refer to #3557 , it also a api server module test case improve issue.

Remember leave a message before you implement it~

close by #3563

Was this page helpful?
0 / 5 - 0 ratings