You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: java-bigquery/google-cloud-bigquery/src/main/java/com/google/cloud/bigquery/telemetry/BigQueryTelemetryTracer.java
+1-9Lines changed: 1 addition & 9 deletions
Original file line number
Diff line number
Diff line change
@@ -32,9 +32,8 @@ public final class BigQueryTelemetryTracer {
Copy file name to clipboardExpand all lines: java-bigquery/google-cloud-bigquery/src/main/java/com/google/cloud/bigquery/telemetry/HttpTracingRequestInitializer.java
+5-2Lines changed: 5 additions & 2 deletions
Original file line number
Diff line number
Diff line change
@@ -51,6 +51,9 @@ public class HttpTracingRequestInitializer implements HttpRequestInitializer {
Copy file name to clipboardExpand all lines: java-bigquery/google-cloud-bigquery/src/test/java/com/google/cloud/bigquery/telemetry/BigQueryTelemetryTracerTest.java
-3Lines changed: 0 additions & 3 deletions
Original file line number
Diff line number
Diff line change
@@ -181,9 +181,6 @@ public void testAddCommonAttributeToSpan() {
Copy file name to clipboardExpand all lines: java-bigquery/google-cloud-bigquery/src/test/java/com/google/cloud/bigquery/telemetry/HttpTracingRequestInitializerTest.java
You need Java 11 or higher to run the build. The build produces Java 8-compatible
4
+
bytecode.
5
+
6
+
Install [`bazelisk`](https://github.com/bazelbuild/bazelisk) in your `PATH`
7
+
for gapic-generator-java's Bazel build.
8
+
9
+
## Set Up
10
+
11
+
1. Clone this repo.
12
+
13
+
2. (OPTIONAL) Copy the Git pre-commit hooks. This will automatically check the build, run
14
+
tests, and perform linting before each commit. (Symlinks don't seem to work,
15
+
but if you find a way, please add it here!)
16
+
17
+
```sh
18
+
cp .githooks/pre-commit .git/hooks/pre-commit
19
+
```
20
+
21
+
## Run Tests for All Modules
22
+
23
+
- Run all unit tests in all modules.
24
+
25
+
```sh
26
+
mvn install
27
+
```
28
+
29
+
## Code Formatting
30
+
31
+
- Run linter checks without actually doing the formatting.
32
+
33
+
```sh
34
+
mvn fmt:check
35
+
```
36
+
37
+
- Format files.
38
+
39
+
```sh
40
+
mvn fmt:format
41
+
```
42
+
43
+
## Testing guide
44
+
There are 4 layers of testing in this repo:
45
+
1. Traditional unit tests. These tests usually focus on testing one very specific testcase at a time. For example, [MethodTest](https://github.com/googleapis/google-cloud-java/blob/main/sdk-platform-java/gapic-generator-java/src/test/java/com/google/api/generator/gapic/model/MethodTest.java)
46
+
2. Golden unit tests. These tests start with a test proto, we create different test cases in the proto, load the proto in unit tests and save the generated file as golden files. For example, [routing header proto](https://github.com/googleapis/google-cloud-java/blob/main/sdk-platform-java/gapic-generator-java/src/test/proto/explicit_dynamic_routing_header_testing.proto) -> Load in the [unit test](https://github.com/googleapis/google-cloud-java/blob/main/sdk-platform-java/gapic-generator-java/src/test/java/com/google/api/generator/gapic/composer/grpc/GrpcServiceStubClassComposerTest.java#L56-L64) -> Saved as [golden](https://github.com/googleapis/google-cloud-java/blob/main/sdk-platform-java/gapic-generator-java/src/test/java/com/google/api/generator/gapic/composer/grpc/goldens/GrpcRoutingHeadersStub.golden)
47
+
3. Showcase integration tests. They test the generated library's behavior against a mock server, see [README.md](https://github.com/googleapis/google-cloud-java/blob/main/sdk-platform-java/java-showcase/README.md) of showcase module for details.
48
+
4. Golden integration tests. These tests generate a full client library with real protos from googleapis, for example, golden integration tests for [compute](https://github.com/googleapis/sdk-platform-java/tree/main/test/integration/goldens/compute). However, we _should_ stop adding new ones, and rely on golden unit tests and showcase tests.
49
+
50
+
Based on where the code changes are, we should add different tests, in general
51
+
52
+
- If the changes are in `gax` or `api-common` only, you _must_ add traditional unit tests, you _may_ add showcase integration tests if you are modifying a public setting.
53
+
- If the changes are in `gapic-generator-java` only, showcase integration tests are most likely not needed
54
+
- If they are in the `composer` module, you _must_ add golden unit tests, you _may_ add traditional unit tests for better coverage and easier testing.
55
+
- If they are in the `parser` module, you _should_ add traditional unit tests with a test proto if possible, you _may_ add golden unit tests to easily see the changes. For example, [routing_rule_parser_testing](https://github.com/googleapis/google-cloud-java/blob/main/sdk-platform-java/gapic-generator-java/src/test/proto/routing_rule_parser_testing.proto) that is only used for testing [RoutingRuleParser](https://github.com/googleapis/google-cloud-java/blob/main/sdk-platform-java/gapic-generator-java/src/main/java/com/google/api/generator/gapic/protoparser/RoutingRuleParser.java).
56
+
- If they are in `other modules(ast, model, writer etc.)`, you _must_ add traditional unit tests, you _may_ add golden unit tests to easily see the changes.
57
+
- If the changes are in both `gax` and `gapic-generator-java`, you _must_ add all test layers, including traditional unit tests, golden unit tests and showcase integration tests.
58
+
59
+
### How to run tests?
60
+
61
+
See the [Unit Tests](https://github.com/googleapis/google-cloud-java/blob/main/sdk-platform-java/gapic-generator-java/DEVELOPMENT.md#unit-tests) section in gapic-generator-java/DEVELOPMENT.md for how to run traditional and golden unit tests.
62
+
63
+
See [Running the Integration Tests](https://github.com/googleapis/google-cloud-java/blob/main/sdk-platform-java/java-showcase/README.md#running-the-integration-tests) and [Update the Golden Showcase Files](https://github.com/googleapis/google-cloud-java/blob/main/sdk-platform-java/java-showcase/README.md#update-the-golden-showcase-files) sections in java-showcase/README.md for how to run and update showcase integration tests.
64
+
65
+
See the [Integration Tests](https://github.com/googleapis/google-cloud-java/blob/main/sdk-platform-java/gapic-generator-java/DEVELOPMENT.md#integration-tests) section in gapic-generator-java/DEVELOPMENT.md for how to run golden integration tests.
0 commit comments