# CustomTestOptions

Properties for specifying a test.

Used as argument in: [Test.custom](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_synthetics.Test.html#custom)

- Source: [`aws-synthetics/lib/canary.ts`](https://github.com/aws/aws-cdk/blob/v2.278.0/packages/aws-cdk-lib/aws-synthetics/lib/canary.ts#L68)
- Type last changed: v2.99.0 · 28 Sep 2023

## Example

TypeScript:

```ts
import * as cdk from 'aws-cdk-lib';

const canary = new synthetics.Canary(this, 'MyCanary', {
  schedule: synthetics.Schedule.rate(Duration.minutes(5)),
  test: synthetics.Test.custom({
    code: synthetics.Code.fromAsset(path.join(__dirname, 'canary')),
    handler: 'index.handler',
  }),
  runtime: synthetics.Runtime.SYNTHETICS_NODEJS_PUPPETEER_6_2,
  memory: cdk.Size.mebibytes(1024), // 1024 MiB
});
```

Python:

```python
import aws_cdk as cdk

canary = synthetics.Canary(self, "MyCanary",
    schedule=synthetics.Schedule.rate(Duration.minutes(5)),
    test=synthetics.Test.custom(
        code=synthetics.Code.from_asset(path.join(__dirname, "canary")),
        handler="index.handler"
    ),
    runtime=synthetics.Runtime.SYNTHETICS_NODEJS_PUPPETEER_6_2,
    memory=cdk.Size.mebibytes(1024)
)
```

Java:

```java
import software.amazon.awscdk.*;

Canary canary = Canary.Builder.create(this, "MyCanary")
        .schedule(Schedule.rate(Duration.minutes(5)))
        .test(Test.custom(CustomTestOptions.builder()
                .code(Code.fromAsset(join(__dirname, "canary")))
                .handler("index.handler")
                .build()))
        .runtime(Runtime.SYNTHETICS_NODEJS_PUPPETEER_6_2)
        .memory(Size.mebibytes(1024))
        .build();
```

C# / .NET:

```csharp
// Install: dotnet add package Amazon.CDK.Lib
using Amazon.CDK;

var canary = new Canary(this, "MyCanary", new CanaryProps {
    Schedule = Schedule.Rate(Duration.Minutes(5)),
    Test = Test.Custom(new CustomTestOptions {
        Code = Code.FromAsset(Join(__dirname, "canary")),
        Handler = "index.handler"
    }),
    Runtime = Runtime.SYNTHETICS_NODEJS_PUPPETEER_6_2,
    Memory = Size.Mebibytes(1024)
});
```

Golang:

```go
// Install: go get github.com/aws/aws-cdk-go/awscdk/v2
import cdk "github.com/aws/aws-cdk-go/awscdk"

canary := synthetics.NewCanary(this, jsii.String("MyCanary"), &CanaryProps{
	Schedule: synthetics.Schedule_Rate(awscdk.Duration_Minutes(jsii.Number(5))),
	Test: synthetics.Test_Custom(&CustomTestOptions{
		Code: synthetics.Code_FromAsset(path.join(__dirname, jsii.String("canary"))),
		Handler: jsii.String("index.handler"),
	}),
	Runtime: synthetics.Runtime_SYNTHETICS_NODEJS_PUPPETEER_6_2(),
	Memory: cdk.Size_Mebibytes(jsii.Number(1024)),
})
```

## Properties

- `code`: [Code](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_synthetics.Code.html) (required) — The code of the canary script.

- `handler`: string (required) — The handler for the code.

  Must end with `.handler`.
