Skip to content

[CI/CD]Add unit test #1465

@khadgarmage

Description

@khadgarmage

follow the root issue: #1460
Notice:

  • The ut coverage is required to reach 60%
  • UT only use junit and mockito, we worried about license issues after other library is introduced
  • UT cannot include performance testing operations, blocking operations (time-consuming), and cannot rely on third-party libs. If you want to rely on testing, you can use mockito to mock.

The directory listing which will write ut is as following(if you want to contribute, you may reply "java.org.apache.dolphinscheduler.api.utils, i want to implement it, avoid everyone writing UT repeatedly):

├── java
│   └── org
│       └── apache
│           └── dolphinscheduler
│               └── api
│                   ├── ApiApplicationServer.java
│                   ├── CombinedApplicationServer.java
│                   ├── configuration
│                   ├── controller
│                   ├── dto
│                   ├── enums
│                   ├── interceptor
│                   ├── log
│                   ├── service
│                   └── utils

├── java
│   └── org
│       └── apache
│           └── dolphinscheduler
│               └── common
│                   ├── Constants.java
│                   ├── IStoppable.java
│                   ├── enums
│                   ├── graph
│                   ├── job
│                   ├── model
│                   ├── process
│                   ├── queue
│                   ├── shell
│                   ├── task
│                   ├── thread
│                   ├── utils
│                   └── zk

├── java
│   └── org
│       └── apache
│           └── dolphinscheduler
│               └── alert
│                   ├── AlertServer.java
│                   ├── manager
│                   ├── runner
│                   └── utils

If you had finished the ut, you should modify the pom.xml file, and add the include files like this:

			<plugin>
				<groupId>org.apache.maven.plugins</groupId>
				<artifactId>maven-surefire-plugin</artifactId>
				<version>${maven-surefire-plugin.version}</version>
				<configuration>
					<includes>
						<include>**/common/graph/*.java</include><!--run test classes-->
					</includes>
					<!-- <skip>true</skip> -->
				</configuration>
			</plugin>

Note: Now, ci has support db, if you develop mapper/dao ut, you can use it, and it had config in dolphinscheduler-dao/src/main/resources/application-dao.properties

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions