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

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.

主站蜘蛛池模板: 阳高县| 通榆县| 镇康县| 拉萨市| 濮阳市| 肥乡县| 阳城县| 当雄县| 阜阳市| 中西区| 雅江县| 梁山县| 和平区| 开远市| 西乌珠穆沁旗| 沙坪坝区| 临汾市| 重庆市| 木兰县| 原阳县| 称多县| 巴林右旗| 乌鲁木齐市| 磐石市| 鹤山市| 阳朔县| 西宁市| 准格尔旗| 龙井市| 包头市| 虹口区| 万安县| 吉首市| 平和县| 潼南县| 分宜县| 沁阳市| 明星| 杭锦旗| 广平县| 灌云县|