I'm trying to make a test-case to check for the Dropwizard Metric Meter name: Here's the code:
@Test
public void getMeterName(){
String metricsPrefix = "com.company.team";
String tagSupplied = "tenant.db.table";
String expectedMeterName = "com.company.team.tenant.db.table";
assertSame(expectedMeterName,MetricRegistry.name(metricsPrefix,tagSupplied));
}
This is the error I'm getting:
java.lang.AssertionError: expected same:<com.company.team.tenant.db.table> was not:<com.company.team.tenant.db.table>
Expected :com.company.team.tenant.db.table
Actual :com.company.team.tenant.db.table
What am I missing here?
What am I missing here?
The strings that you are testing are equal but not the same object.
You are using assertSame
where you should be using assertEquals
.
This is analogous to the mistake of using ==
to compare strings.
(See also: How do I compare strings in Java?)