22
22
* [ Exception Handling] ( )
23
23
* [ Client Initialization] ( #client-initialization )
24
24
* [ Command-Line Arguments] ( #command-line-arguments )
25
+ * [ Preferred Dependencies] ( #preferred-dependencies )
25
26
* [ Modern Java] ( #modern-java )
26
27
* [ Lambdas] ( #lambdas )
27
28
* [ Streams] ( #streams )
@@ -77,8 +78,10 @@ correctly - it is an explicit non goal for tests to verify that API is performin
77
78
Because of this, mocks for external services are strongly discouraged.
78
79
79
80
* Test Library: [ JUnit4] ( https://junit.org/junit4/ )
80
- * Test Runner: [ Maven Failsafe plugin] ( https://maven.apache.org/surefire/maven-failsafe-plugin/ )
81
- and [ Maven Surefire plugin] ( https://maven.apache.org/surefire/maven-surefire-plugin/ ) .
81
+ * Test Runner: [ Maven Failsafe plugin] ( https://maven.apache.org/surefire/maven-failsafe-plugin/ )
82
+ (Integration Tests) and [ Maven Surefire plugin] ( https://maven.apache.org/surefire/maven-surefire-plugin/ ) (Unit Tests).
83
+
84
+ Most of our sample tests are Integration Tests and should be marked as such using either the Prefix or suffix ` IT ` .
82
85
83
86
As an example, the following test code shows how we test a region tag (region tags are tools Google
84
87
uses to identify sections of the snippets to be highlighted in documentation) called ` region_tag ` :
@@ -95,7 +98,7 @@ import org.junit.runners.JUnit4;
95
98
* Store region_tag in test method name, camel-cased
96
99
*/
97
100
@RunWith (JUnit4 . class)
98
- public class SomeClassTest {
101
+ public class SomeClassIT {
99
102
@Test public void regionTag_shouldPass () throws Exception { }
100
103
101
104
@Test public void regionTag_shouldFail () throws Exception {
@@ -159,10 +162,8 @@ To run the `functions` tests (or other tests without a parent `pom.xml`), use th
159
162
```
160
163
cd functions
161
164
find */pom.xml | xargs -I {} echo $(pwd)/{} | xargs -I {} dirname {} | xargs -I {} sh -c "cd {} && mvn clean verify"
162
-
163
165
```
164
166
165
-
166
167
### Gradle Specifics
167
168
#### NEEDS WORK
168
169
Your ` build.gradle ` should have the following section:
@@ -396,6 +397,12 @@ considered an anti-pattern, and new samples should not implement them.
396
397
397
398
**Dataflow** samples are an exception to this guideline.
398
399
400
+ ### Preferred Dependencies
401
+ Google written dependencies are always preferred over alternatives. For example:
402
+ * [Guava](https://github.com/Google/Guava) is preferred over [Apache commons lang](https://commons.apache.org/)
403
+ * [GSON](https://github.com/Google/GSON) is preferred for JSON parsing.
404
+ * [Google HTTP Client](https://github.com/googleapis/google-http-java-client) is preferred.
405
+
399
406
## Modern Java
400
407
Prefer using modern idioms / language features over older styles.
401
408
0 commit comments