- Scala for Java Developers
- Thomas Alexandre
- 149字
- 2021-07-16 11:58:37
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.
推薦閱讀
- Getting Started with Gulp(Second Edition)
- 深入淺出Prometheus:原理、應用、源碼與拓展詳解
- Learning Python Design Patterns(Second Edition)
- R的極客理想:工具篇
- .NET 3.5編程
- Learning Unreal Engine Android Game Development
- Kivy Cookbook
- Getting Started with Nano Server
- Elasticsearch Essentials
- Java Web應用開發項目教程
- 基于GPU加速的計算機視覺編程:使用OpenCV和CUDA實時處理復雜圖像數據
- Python滲透測試編程技術:方法與實踐(第2版)
- 創新工場講AI課:從知識到實踐
- Django 2.0 入門與實踐
- Java EE應用開發及實訓