Last active
June 27, 2019 13:04
-
-
Save ufuk/0ccb87185c22475c64d46801fa160777 to your computer and use it in GitHub Desktop.
Just another reason to why you shouldn't use Lombok, in another saying another reason to why you should write unit tests: You have two fields in your class. Fields are in the same type. You use @AllArgsConstructor to auto-generate your all args constructor. It works for a moment, until you change the order of the field.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import lombok.AllArgsConstructor; | |
import lombok.Data; | |
@Data | |
@AllArgsConstructor | |
public class LazyDeveloper { | |
private String firstName; | |
private String lastName; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import org.junit.Test; | |
import static org.hamcrest.Matchers.equalTo; | |
import static org.junit.Assert.assertThat; | |
public class LazyDeveloperTest { | |
@Test | |
public void testAllArgsConstructor() { | |
LazyDeveloper lazyDeveloper = new LazyDeveloper("John", "Doe"); | |
assertThat(lazyDeveloper.getFirstName(), equalTo("John")); | |
assertThat(lazyDeveloper.getLastName(), equalTo("Doe")); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
@Kidlike great addition, thank you. I encountered such a situation when using Lombok and just noted it.