- 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.
推薦閱讀
- Mastering Concurrency Programming with Java 8
- INSTANT Mock Testing with PowerMock
- 造個小程序:與微信一起干件正經事兒
- 劍指JVM:虛擬機實踐與性能調優
- Lua程序設計(第4版)
- Oracle BAM 11gR1 Handbook
- 零基礎學Python數據分析(升級版)
- Mastering ServiceNow(Second Edition)
- Web Development with MongoDB and Node(Third Edition)
- NGINX Cookbook
- 零基礎學C語言程序設計
- Java 11 and 12:New Features
- Learning D3.js 5 Mapping(Second Edition)
- Building Scalable Apps with Redis and Node.js
- 大象:Thinking in UML(第二版)