aws / aws/aws-sam-cli

Can not find test results of a failing junit java test

Open
#2,630 4 comments 1 reaction 0 assignees View on GitHub
area/build maintainer/need-followup
Dominant language
Python
Stars
6.7k
Forks
1.2k
Avg merge
1d 10h
Merged PRs (30d)
52

Description

### Description:

We have build a sam application which builds fine. We use lambdas with java 11.
But when a junit test fails, it is not possible to find the test results.

`sam build` fails and displays the message:

```12 tests completed, 1 failed

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':functions:myLambdaFunctionName:test'.
> There were failing tests. See the report at: file:///tmp/tmpqosckf5f/52a6aed018378fb1d5d20fd90e15b59b24f876fe/build/reports/tests/test/index.html
```

But there is no /tmp/tmpqosckf5f/ directory on my machine. My current workaround is building again with gradle but that is no solution for a CI Run.

### Steps to reproduce:

* create a java 11 lambda
* create a failing test
* run `sam build`

### Observed result:

```
$:~/ideaprojects/my-service$ sam build --debug
2021-02-15 15:02:21,524 | Telemetry endpoint configured to be https://aws-serverless-tools-telemetry.us-west-2.amazonaws.com/metrics
2021-02-15 15:02:21,527 | 'build' command is called
....
2021-02-15 15:02:21,626 | 17 resources found in the template
2021-02-15 15:02:21,626 | Found Serverless function with name='MyLambdaFunctionName' and CodeUri='functions/myLambdaFunctionName'
....
2021-02-15 15:02:21,676 | Instantiating build definitions
2021-02-15 15:02:21,688 | Same build definition found, adding function (Previous: BuildDefinition(java11, functions/myLambdaFunctionName, a5b10daa-8034-4aa5-9efd-be9addae8f0e, {}, []), Current: BuildDefinition(java11, functions/myLambdaFunctionName, da8bf9cf-bb46-4c7d-a04e-2d6a9dc1f20f, {}, []), Function: Function(name='MyLambdaFunctionName', functionname='MyLambdaFunctionName', runtime='java11', memory=512, timeout=60, handler='com.x.Handler', codeuri='functions/myLambdaFunctionName', environment={'Variables': {......}}, metadata=None))
....
2021-02-15 15:02:21,706 | Found workflow 'JavaGradleWorkflow' to support capabilities 'Capability(language='java', dependency_manager='gradle', application_framework=None)'
2021-02-15 15:02:22,355 | Running workflow 'JavaGradleWorkflow'
2021-02-15 15:02:22,357 | Running JavaGradleWorkflow:GradleBuild
2021-02-15 15:02:29,871 | JavaGradleWorkflow:GradleBuild succeeded
2021-02-15 15:02:29,871 | Running JavaGradleWorkflow:CopyArtifacts
2021-02-15 15:02:29,905 | JavaGradleWorkflow:CopyArtifacts succeeded
....
2021-02-15 15:02:39,527 | Building codeuri: functions/myLambdaFunctionName runtime: java11 metadata: {} functions: ['MyLambdaFunctionName']
2021-02-15 15:02:39,527 | Building to following folder /home/joerg/ideaprojects/my-service/.aws-sam/build/MyLambdaFunctionName
2021-02-15 15:02:39,527 | Looking for a supported build workflow in following directories: ['/home/joerg/ideaprojects/my-service/functions/myLambdaFunctionName', '/home/joerg/ideaprojects/my-service']
2021-02-15 15:02:39,527 | Loading workflow module 'aws_lambda_builders.workflows'
2021-02-15 15:02:39,528 | Found workflow 'JavaGradleWorkflow' to support capabilities 'Capability(language='java', dependency_manager='gradle', application_framework=None)'
2021-02-15 15:02:40,177 | Running workflow 'JavaGradleWorkflow'
2021-02-15 15:02:40,177 | Running JavaGradleWorkflow:GradleBuild
2021-02-15 15:02:51,345 | JavaGradleWorkflow:GradleBuild failed
Traceback (most recent call last):
File "/home/linuxbrew/.linuxbrew/Cellar/aws-sam-cli/1.8.0/libexec/lib/python3.8/site-packages/aws_lambda_builders/workflows/java_gradle/actions.py", line 47, in _build_project
self.subprocess_gradle.build(
File "/home/linuxbrew/.linuxbrew/Cellar/aws-sam-cli/1.8.0/libexec/lib/python3.8/site-packages/aws_lambda_builders/workflows/java_gradle/gradle.py", line 45, in build
raise GradleExecutionError(message=stderr.decode("utf8").strip())
aws_lambda_builders.workflows.java_gradle.gradle.GradleExecutionError: Gradle Failed: WARNING: An illegal reflective access operation has occurred
WARNING: Illegal reflective access by org.mockito.cglib.core.ReflectUtils$2 ....
WARNING: Please consider reporting this to the maintainers of org.mockito.cglib.core.ReflectUtils$2
WARNING: Use --illegal-access=warn to enable warnings of further illegal reflective access operations
WARNING: All illegal access operations will be denied in a future release

12 tests completed, 1 failed

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':functions:myLambdaFunctionName:test'.
> There were failing tests. See the report at: file:///tmp/tmp4oofhjdx/52a6aed018378fb1d5d20fd90e15b59b24f876fe/build/reports/tests/test/index.html

* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.

* Get more help at https://help.gradle.org

BUILD FAILED in 10s

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "/home/linuxbrew/.linuxbrew/Cellar/aws-sam-cli/1.8.0/libexec/lib/python3.8/site-packages/aws_lambda_builders/workflow.py", line 269, in run
action.execute()
File "/home/linuxbrew/.linuxbrew/Cellar/aws-sam-cli/1.8.0/libexec/lib/python3.8/site-packages/aws_lambda_builders/workflows/java_gradle/actions.py", line 29, in execute
self._build_project(init_script_file)
File "/home/linuxbrew/.linuxbrew/Cellar/aws-sam-cli/1.8.0/libexec/lib/python3.8/site-packages/aws_lambda_builders/workflows/java_gradle/actions.py", line 55, in _build_project
raise ActionFailedError(str(ex))
aws_lambda_builders.actions.ActionFailedError: Gradle Failed: WARNING: An illegal reflective access operation has occurred
WARNING: Illegal reflective access by org.mockito.cglib.core.ReflectUtils$2 ....
WARNING: Please consider reporting this to the maintainers of org.mockito.cglib.core.ReflectUtils$2
WARNING: Use --illegal-access=warn to enable warnings of further illegal reflective access operations
WARNING: All illegal access operations will be denied in a future release

12 tests completed, 1 failed

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':functions:myLambdaFunctionName:test'.
> There were failing tests. See the report at: file:///tmp/tmp4oofhjdx/52a6aed018378fb1d5d20fd90e15b59b24f876fe/build/reports/tests/test/index.html

* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.

* Get more help at https://help.gradle.org

BUILD FAILED in 10s

Build Failed
....

12 tests completed, 1 failed

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':functions:myLambdaFunctionName:test'.
> There were failing tests. See the report at: file:///tmp/tmp4oofhjdx/52a6aed018378fb1d5d20fd90e15b59b24f876fe/build/reports/tests/test/index.html

* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.

* Get more help at https://help.gradle.org

BUILD FAILED in 10s
```

### Expected result:

I'd like to have a defined directory where I can find the reports of the failing tests. It would be also ok if I could specify the directory name by a flag

### Additional environment details (Ex: Windows, Mac, Amazon Linux etc)

1. OS: Ubuntu 18.04
2. `sam --version`: SAM CLI, version 1.8.0
3. AWS region: only local build

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.