求助求助, idea 2023.2 版本自动执行单元测试问题,只要修改了任意代码, idea 就会自动编译并自动运行单元测试,这是怎么回事?太烦了啊 - V2EX
V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
请不要在回答技术问题时复制粘贴 AI 生成的内容
itechnology
V2EX    程序员

求助求助, idea 2023.2 版本自动执行单元测试问题,只要修改了任意代码, idea 会自动编译并自动运行单元测试,这是怎么回事?太烦了啊

  •  
  •   itechnology 2023-12-08 16:13:11 +08:00 2073 次点击
    这是一个创建于 702 天前的主题,其中的信息可能已经有所发展或是发生改变。

    我在 idea 中新建了一个多模块的 maven 项目(模块 A 和模块 B ),现在是模块 B 中写了以下单元测试代码:

    @SpringBootTest(classes = CodeGeneratorApplication.class) public class CodeGeneratorTests { @Test public void generator() { // 单元测试代码省略 } 

    现在有个问题是,只要执行过一次这个单元测试,那么一旦在任何模块中修改了代码,idea 就会立即自动编译并自动运行这个单元测试,例如修改了模块 A 的代码(模块 A 和模块 B 之间没有依赖关系),即使是按了下 Tab 键,idea 也会立即自动编译并自动运行这个单元测试,已经确认“Toggle 'Skip Tests' Mode”是按下状态。

    模块 A 的 pom.xml 文件中 build 部分内容为:

    <build> <plugins> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-compiler-plugin</artifactId> <version>3.8.1</version> <configuration> <source>1.8</source> <target>1.8</target> <encoding>UTF-8</encoding> </configuration> </plugin> <plugin> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-maven-plugin</artifactId> <version>${spring-boot.version}</version> <configuration> <mainClass>com.xxx.cloud.uas.UasApplication</mainClass> <skip>true</skip> </configuration> <executions> <execution> <id>repackage</id> <goals> <goal>repackage</goal> </goals> </execution> </executions> </plugin> </plugins> </build> 

    模块 B 的 pom.xml 文件中 build 部分内容为:

    <build> <plugins> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-compiler-plugin</artifactId> <version>3.8.1</version> <configuration> <source>1.8</source> <target>1.8</target> <encoding>UTF-8</encoding> </configuration> </plugin> <plugin> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-maven-plugin</artifactId> <version>${spring-boot.version}</version> <configuration> <mainClass>com.xxx.code.generator.CodeGeneratorApplication</mainClass> <skip>true</skip> </configuration> <executions> <execution> <id>repackage</id> <goals> <goal>repackage</goal> </goals> </execution> </executions> </plugin> </plugins> </build> 
    7 条回复    2023-12-12 09:42:26 +08:00
    itechnology
        1
    itechnology  
    OP
       2023-12-08 16:30:11 +08:00
    但是如果出现这个问题之后把这个 workspace 关掉重新打开并不执行单元测试,这个问题就不复存在,感觉好神奇
    gaojjx
        2
    gaojjx  
       2023-12-08 17:01:40 +08:00
    gaojjx
        3
    gaojjx  
       2023-12-08 17:03:35 +08:00
    https://www.jetbrains.com/idea/whatsnew/2023-2/ 在 Run/Debug部分有说明,更新内容都不看吗
    itechnology
        4
    itechnology  
    OP
       2023-12-08 17:14:37 +08:00
    @gaojjx 解决了,还真是这个问题,非常感谢。平常我升级软件不咋注意更新内容,所以没注意到这块更新内容。
    equationzhao
        5
    equationzhao  
       2023-12-08 19:24:28 +08:00
    之前也遇到过这个, 后来发现在测试窗口有个选项,关了就好
    kneo
        6
    kneo  
       2023-12-08 21:57:10 +08:00 via Android
    就 jetbrains 现在的摆烂状态,更新内容我根本不看了。
    itechnology
        7
    itechnology  
    OP
       2023-12-12 09:42:26 +08:00
    @equationzhao 主要是不会想到是这里的问题,谁能想到是在 test 执行后的窗口去设置
    关于     帮助文档     自助推广系统     博客     API     FAQ     Solana     2662 人在线   最高记录 6679       Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 29ms UTC 09:05 PVG 17:05 LAX 01:05 JFK 04:05
    Do have faith in what you're doing.
    ubao msn snddm index pchome yahoo rakuten mypaper meadowduck bidyahoo youbao zxmzxm asda bnvcg cvbfg dfscv mmhjk xxddc yybgb zznbn ccubao uaitu acv GXCV ET GDG YH FG BCVB FJFH CBRE CBC GDG ET54 WRWR RWER WREW WRWER RWER SDG EW SF DSFSF fbbs ubao fhd dfg ewr dg df ewwr ewwr et ruyut utut dfg fgd gdfgt etg dfgt dfgd ert4 gd fgg wr 235 wer3 we vsdf sdf gdf ert xcv sdf rwer hfd dfg cvb rwf afb dfh jgh bmn lgh rty gfds cxv xcv xcs vdas fdf fgd cv sdf tert sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf shasha9178 shasha9178 shasha9178 shasha9178 shasha9178 liflif2 liflif2 liflif2 liflif2 liflif2 liblib3 liblib3 liblib3 liblib3 liblib3 zhazha444 zhazha444 zhazha444 zhazha444 zhazha444 dende5 dende denden denden2 denden21 fenfen9 fenf619 fen619 fenfe9 fe619 sdf sdf sdf sdf sdf zhazh90 zhazh0 zhaa50 zha90 zh590 zho zhoz zhozh zhozho zhozho2 lislis lls95 lili95 lils5 liss9 sdf0ty987 sdft876 sdft9876 sdf09876 sd0t9876 sdf0ty98 sdf0976 sdf0ty986 sdf0ty96 sdf0t76 sdf0876 df0ty98 sf0t876 sd0ty76 sdy76 sdf76 sdf0t76 sdf0ty9 sdf0ty98 sdf0ty987 sdf0ty98 sdf6676 sdf876 sd876 sd876 sdf6 sdf6 sdf9876 sdf0t sdf06 sdf0ty9776 sdf0ty9776 sdf0ty76 sdf8876 sdf0t sd6 sdf06 s688876 sd688 sdf86