Skip to content

Commit 3a01d58

Browse files
committed
test fail when SERPAPI_KEY is null
1 parent c610e50 commit 3a01d58

File tree

4 files changed

+18
-10
lines changed

4 files changed

+18
-10
lines changed

src/test/java/serpapi/AccountApiTest.java

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,15 @@
1212
import static org.junit.Assert.*;
1313
import static org.mockito.Mockito.*;
1414

15+
/***
16+
* Test SerpApi.account() method.
17+
*/
1518
public class AccountApiTest {
1619

1720
@Test
1821
public void account() throws Exception {
1922
if (System.getenv("SERPAPI_KEY") == null) {
20-
return;
23+
fail("SERPAPI_KEY is not set");
2124
}
2225

2326
Map<String, String> parameter = new HashMap<String, String>();

src/test/java/serpapi/LocationApiTest.java

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,12 +13,16 @@
1313
import static org.junit.Assert.*;
1414
import static org.mockito.Mockito.*;
1515

16+
/**
17+
* Test SerpApi.location() method.
18+
*/
1619
public class LocationApiTest {
1720

1821
@Test
1922
public void location() throws Exception {
20-
if(System.getenv("SERPAPI_KEY") == null)
21-
return;
23+
if(System.getenv("SERPAPI_KEY") == null) {
24+
fail("SERPAPI_KEY is not set");
25+
}
2226

2327
SerpApi serpapi = new SerpApi();
2428

src/test/java/serpapi/SearchApiTest.java

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,15 +10,16 @@
1010
import static org.junit.Assert.*;
1111

1212
/**
13-
* Test main class
13+
* Test SerpApi.search() method.
1414
*/
1515
public class SearchApiTest {
1616

1717
@Test
1818
public void search() throws SerpApiException, InterruptedException {
1919
// skip test if no api_key provided
20-
if(System.getenv("SERPAPI_KEY") == null)
21-
return;
20+
if(System.getenv("SERPAPI_KEY") == null) {
21+
fail("SERPAPI_KEY is not set");
22+
}
2223

2324
Map<String, String> auth = new HashMap<>();
2425
auth.put("api_key", System.getenv("SERPAPI_KEY"));

src/test/java/serpapi/SearchArchiveApiTest.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,16 +10,16 @@
1010
import static org.junit.Assert.*;
1111

1212
/**
13-
* Test main class
13+
* Test SerpApi.searchArchive() method.
1414
*/
1515
public class SearchArchiveApiTest {
1616

17-
1817
@Test
1918
public void searchArchive() throws SerpApiException, InterruptedException {
2019
// skip test if no api_key provided
21-
if(System.getenv("SERPAPI_KEY") == null)
22-
return;
20+
if(System.getenv("SERPAPI_KEY") == null) {
21+
fail("SERPAPI_KEY is not set");
22+
}
2323

2424
Map<String, String> parameter = new HashMap<>();
2525
parameter.put("api_key", System.getenv("SERPAPI_KEY"));

0 commit comments

Comments
 (0)