我正在尝试使用Travis CI自动运行测试。我只是找不到关于如何在Java中执行此操作的好教程。当我推送到GitHub时,我在Travis中不断收到以下错误:
命令“ ./mvnw干净安装”以127退出。
我的.travis.yml文件如下所示:
language: java
jdk:
- openjdk11
script: ./mvnw clean install
这是我的测试班
package server;
import org.junit.jupiter.api.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.autoconfigure.web.servlet.WebMvcTest;
import org.springframework.test.context.junit4.SpringRunner;
import org.springframework.test.web.servlet.MockMvc;
import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.get;
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status;
@WebMvcTest(CoffeeController.class)
@RunWith(SpringRunner.class)
class CoffeeControllerTest {
@Autowired
private MockMvc mockMvc;
@Test
void getAllCoffee() {
try {
mockMvc.perform(get("/coffee/all")).andExpect(status().isOk());
} catch (Exception e) {
e.printStackTrace();
}
}
}
我在Youtube和网络上搜索了几本教程,但似乎无法获得答案。希望大家能帮助我。我非常感激!我也试图删除该脚本,但也没有成功。
我认为您应该将脚本值更改为此:脚本:./ mvn全新安装
我不确定,但您可以尝试