小编rav*_*ter的帖子

VM 因具有 module-info.java 的 maven-surefire-plugin 崩溃

最初,我在下一个文件夹中有一个独特的模块信息: src/main/java/module-info.java.

我能够成功运行测试。

现在我需要覆盖,module-info因为我需要添加一些仅与测试相关的更改。更改是关于打开模块。我在这里添加这个新内容module-info.java: src/main/test/module-info.java。

如果我用它执行测试,我会收到下一个错误:

[ERROR] Failed to execute goal org.apache.maven.plugins:maven-surefire-plugin:3.0.0-M4:test (default-test) on project myProject: There are test failures.
[ERROR] 
[ERROR] Please refer to /home/xxxxxx/workspace/myProject/target/surefire-reports for the individual test results.
[ERROR] Please refer to dump files (if any exist) [date].dump, [date]-jvmRun[N].dump and [date].dumpstream.
[ERROR] The forked VM terminated without properly saying goodbye. VM crash or System.exit called?
[ERROR] Command was /bin/sh -c cd /home/xxxxxx/workspace/myProject && /home/xxxxxx/programs/java/jdk-11.0.10/bin/java --add-reads org.eclipse.yasson=ALL-UNNAMED --add-opens org.eclipse.yasson/org.eclipse.yasson.internal.cdi=ALL-UNNAMED --add-exports org.eclipse.yasson/org.eclipse.yasson.internal.cdi=java.naming @/home/xxxxxx/workspace/myProject/target/surefire/surefireargs1904933309274673454 …
Run Code Online (Sandbox Code Playgroud)

java maven-surefire-plugin module-info

5
推荐指数
1
解决办法
1304
查看次数

单元测试Springboot MockMvc返回403禁止

我编写了一个测试UsersController的单元测试。UsersControllerTest.findUser工作正常,但是UsersControllerTest.insertGetModifyDelete不能正常工作。

在测试日志中,我可以看到POST请求与UsersController的任何方法都不匹配,但是我不明白为什么。您能帮我这个吗?

这是我其余的Java类:

@RestController
@RequestMapping("/users")
public class UsersController {

    private final UsersService usersService;

    @Autowired
    public UsersController(UsersService usersService) {
        this.usersService = usersService;
    }

    @GetMapping(value="/{email}", produces="application/json")
    public User get(@PathVariable @Email String email) {
        return usersService.findByEmail(email);
    }

    @PostMapping(consumes="application/json", produces="application/json")
    @ResponseBody
    public ResponseEntity<String> insert(@RequestBody @Valid User user){
        usersService.insert(user);
        return ResponseEntity.ok(user.getEmail());
    }

    @DeleteMapping(value="/{email}", consumes="application/json", produces="application/json")
    public ResponseEntity<String> delete(@PathVariable @Email String email) {
        usersService.delete(email);
        return ResponseEntity.ok(email);
    }

    @PutMapping(value="/{email}", consumes="application/json", produces="application/json")
    public ResponseEntity<User> update(@PathVariable @Email String email, @RequestBody @Valid User user) {
        usersService.update(email, user);
        return ResponseEntity.ok(user);
    } …
Run Code Online (Sandbox Code Playgroud)

java mockmvc

3
推荐指数
3
解决办法
2807
查看次数