【问题标题】:Running individual tests with Jhipster in STS在 STS 中使用 Jhipster 运行单个测试
【发布时间】:2016-05-18 06:45:58
【问题描述】:

我正在尝试为使用 [jHipster 版本 3.3.0][1] 生成的 jHipster 应用程序编写一些新的单元测试,我已将我的项目导入 [STS (w/ Gradle)][2],如果我选择“作为 Spring Boot 应用程序运行”或“作为 Spring Boot 应用程序调试”,它运行良好,并且运行 ./gradlew test 似乎运行所有测试,但是,我想只运行带有 JUnit 集成测试的单个测试[如上所述][3]:

这些测试可以直接在您的 IDE 中运行,只需右键单击每个 测试类,或者通过运行 mvn clean test (或者 ./gradlew test 如果你运行 摇篮)。

当我右键单击我的测试并使用“Run As Junit Test”时,整个应用程序似乎正在运行(尽管它提到 No Profile Selected using Default)。

这是我的简单测试类:

@RunWith(SpringJUnit4ClassRunner.class)
@SpringApplicationConfiguration(classes = MyAPP.class)
@IntegrationTest
@Transactional
public class UtilTest {

    @Test
    public void testGenerateRandomName(){
        Assert.assertNotEquals(null,RandomUtil.generatedRandomWordString());
    }
}

建议?

【问题讨论】:

    标签: jhipster


    【解决方案1】:

    您已将测试声明为使用 MyApp.class 作为 spring 上下文的集成测试,因此您的测试将启动完整的应用程序,这是预期的行为。

    如果您想运行一个简单的单元测试,请删除所有注释。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2018-06-25
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多