官术网_书友最值得收藏!

Adding a test in Scala

For now, we have only Java code in the small sample Maven project. We are ready to introduce a few lines of Scala to the same codebase in order to show how both languages seamlessly interoperate. Let's create a src/test/scala directory, next to the existing java/ directory, where we will put our following new CustomerScalaTest.scala class, which is a similar test to the one we already have under src/test/java:

package com.demo.sample

import org.junit._
import Assert._

class CustomerScalaTest {

  @Before
  def setUp: Unit = {
  }

  @After
  def tearDown: Unit = {
  }

  @Test
  def testGetCustomerId = {
    System.out.println("getCustomerId")
    val instance = new Customer()
    val expResult: Integer = null
    val result: Integer = instance.getCustomerId()
    assertEquals(expResult, result)
  }
}

If we run the tests again, that is, type >mvn clean test again, the class will just be ignored as it is not a .java source file.

主站蜘蛛池模板: 宽甸| 铜川市| 镶黄旗| 城口县| 白银市| 应用必备| 洛川县| 扎赉特旗| 土默特左旗| 鄂尔多斯市| 克拉玛依市| 徐水县| 浑源县| 元氏县| 洱源县| 嘉禾县| 扎兰屯市| 嘉禾县| 习水县| 绥棱县| 芦山县| 凤阳县| 泰和县| 德安县| 巫溪县| 襄樊市| 毕节市| 固原市| 静安区| 台前县| 莱州市| 剑川县| 永德县| 夏河县| 中西区| 宜川县| 滨州市| 佳木斯市| 泰兴市| 搜索| 山阴县|