October 2019
Intermediate to advanced
434 pages
11h 54m
English
Another means of using tests to exercise and improve interop between Java and Kotlin is to use Kotlin code to test our Java code and vice versa. By using Kotlin to test Java, we can test more efficiently by taking advantage of Kotlin features such as data classes and the Kotlin standard library.
To explore this testing interplay between Java and Kotlin, let's walk through an example. Here, we've created a simple Java class called StudentPresenter:
public class StudentPresenter { private List<Student> students; public StudentPresenter(List<Student> students) { students.sort(Comparator.comparing(Student::getLastName)); this.students = students; } public List<Student> getStudents() { return students; }}
We can ...
Read now
Unlock full access