-
Notifications
You must be signed in to change notification settings - Fork 45
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
add deploy action #27
Conversation
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #27 +/- ##
=========================================
Coverage 30.90% 30.90%
Complexity 766 766
=========================================
Files 176 176
Lines 7345 7345
Branches 577 577
=========================================
Hits 2270 2270
Misses 4902 4902
Partials 173 173 ☔ View full report in Codecov by Sentry. |
|
||
- name: Run API Test | ||
run: | | ||
set response $(curl --location 'http://localhost:8080/flow/bg/manage/descriptor/add_descriptor.json?business_id=rillFlowSample&feature_name=choiceSample&alias=release' \ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
应该用测试框架执行测试。
- name: Set up Maven | ||
run: | | ||
sudo apt-get update | ||
sudo apt-get install -y maven |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
setupjdk里包含maven
run: mvn clean package -am && echo "Maven Build and package succeeded" || { echo "Maven Build and package failed."; exit 1; } | ||
|
||
- name: Run Internal Test | ||
run: mvn test && echo "Maven Run Internal Test succeeded"|| { echo "Run Internal Test failed."; exit 1; } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
package包含test
.github/workflows/build.yml
Outdated
@@ -33,13 +33,13 @@ jobs: | |||
- name: Build and analyze | |||
env: | |||
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} | |||
run: mvn -B clean javadoc:javadoc clean verify -P coverage -DskipITs=false -Dmaven.test.skip=false | |||
run: mvn -B clean javadoc:javadoc clean verify -P coverage -DskipITs=false -Dmaven.test.skip=false -pl '!rill-flow-test' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
应该默认不运行rill-flow-test,而不是显式指定不运行
import static org.junit.jupiter.api.Assertions.assertEquals | ||
|
||
@TestInstance(TestInstance.Lifecycle.PER_CLASS) | ||
@TestMethodOrder(MethodOrderer.OrderAnnotation.class) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
应该使用spock的Stepwise
来顺序执行测试
|
||
@Test | ||
@Order(1) | ||
public void testChoiceSampleAddDescriptor() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
这里没有使用spock的基本测试格式
// 执行 API 请求并获取响应 | ||
ApiResponse response = sendApiRequest(url, contentType, requestData); | ||
// 使用测试断言来验证测试结果 | ||
assertEquals(200, response.getStatusCode(), response.getResponseContent()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
这里没有使用spock风格的assert
@TestInstance(TestInstance.Lifecycle.PER_CLASS) | ||
@TestMethodOrder(MethodOrderer.OrderAnnotation.class) | ||
class SampleApiTest extends Specification { | ||
class ApiResponse { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
可以直接用map,不需要单独定义类
int statusCode = response.getStatusLine().getStatusCode(); | ||
String responseContent = EntityUtils.toString(entity); | ||
|
||
return new ApiResponse(statusCode, responseContent); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
可以直接用jsonslurper
解析
private String readFileContent(String filePath) { | ||
try { | ||
// 读取文件内容并返回 | ||
return new String(Files.readAllBytes(Paths.get(filePath))); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
return new File('/path/to/file').text
String contentType = "application/json"; | ||
String requestData = "{\"input_num\":10}"; | ||
ApiResponse response = sendApiRequest(url, contentType, requestData); | ||
assertEquals(200, response.getStatusCode(), response.getResponseContent()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
只验证了状态码,没有验证返回内容和图的业务结果
No description provided.