Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
import com.google.common.collect.ImmutableSet;
import com.google.monitoring.metrics.MetricSchema.Kind;
import org.junit.After;
import org.junit.BeforeClass;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.runners.JUnit4;
Expand All @@ -38,6 +39,16 @@ public class MetricRegistryImplTest {
private final LabelDescriptor label =
LabelDescriptor.create("test_labelname", "test_labeldescription");

/**
* Add {@code unregisterAllMetrics} before the class
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you use @link #unregisterAllMetrics instead?

* in case metrics not unregistered at the beginning
* and cause flaky test
*/
@BeforeClass
public static void beforeClassClearMetrics() {
MetricRegistryImpl.getDefault().unregisterAllMetrics();
}

@After
public void clearMetrics() {
MetricRegistryImpl.getDefault().unregisterAllMetrics();
Expand Down