Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Bugsnag.isStarted #1621

Closed
Closed
Show file tree
Hide file tree
Changes from 1 commit
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 @@ -69,6 +69,15 @@ public static Client start(@NonNull Context androidContext, @NonNull Configurati
return client;
}

/**
* Returns true if one of the <code>start</code> methods have been has been called and
* so Bugsnag is initialized; false if <code>start</code> has not been called and the
* other methods will throw IllegalStateException.
*/
public static boolean isStarted() {
return client != null;
}

private static void logClientInitWarning() {
getClient().logger.w("Multiple Bugsnag.start calls detected. Ignoring.");
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,17 @@ class BugsnagApiTest {
verify(client, times(1)).context = "Bar"
}

@Test
fun isStartedWhenStarted() {
assertEquals(true, Bugsnag.isStarted())
}

@Test
fun isStartedWhenNotStarted() {
Bugsnag.client = null
assertEquals(false, Bugsnag.isStarted())
}

@Test
fun getUser() {
Bugsnag.getUser()
Expand Down