Skip to content

Artman code generation: emitted test code doesn't build #2673

@kmjung

Description

@kmjung

I use artman to generate Java client libraries for my gRPC-based service. Specifically, I'm using the googleapis and toolkit versions from this commit: googleapis/artman@d065fbb.

The emitted production code builds and runs, but the test code doesn't compile as it's emitted. Two fixes are required to make it build:

  1. Gradle dependencies

The following Gradle dependencies are emitted:

dependencies {
  compile project(":grpc-myproject"),
    'com.google.api:gax:1.15.0',
    'com.google.api:gax-grpc:1.15.0',
    'commons-cli:commons-cli:1.4',
    'commons-lang:commons-lang:2.6',
    // This dependency needs to be update-to-date with the version that gRPC expects.
    'io.netty:netty-tcnative-boringssl-static:1.1.33.Fork26'
}

In order to get the test code to build, I have to add dependencies on JUnit and on the test configuration of the gax-grpc library:

dependencies {
  testCompile 'junit:junit:4.11',
    'com.google.api:gax-grpc:1.15.0:testlib'
}
  1. Mock service imports

The test code emits a mock service .java class which imports the service implementation base class from the wrong package. Specifically:

import mypackage.PackageName.MyPackageServiceGrpc.MyPackageServiceImplBase;

... has to be changed to ...

import mypackage.MyPackageServiceGrpc.MyPackageServiceImplBase;

... in order to get the test code to compile.

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions