<commit_before>---
title: Extending Danger extended
subtitle: Plugin engineering
layout: guide_sw
order: 0
blurb: Get your plugin tested
---

### Writing Tests

Danger Swift makes it easy for you to write tests, it includes a second library for importing into your tests. This
library includes a set of functions to get a set-up version of the Danger runtime in your tests.

Edit your `Package.swift` to add a reference to the two Danger libraries:

```diff
    ],
    targets: [
        // Targets are the basic building blocks of a package. A target can define a module or a test suite.
        // Targets can depend on other targets in this package, and on products in packages which this package depends on.
        .target(
            name: "DangerNoCopyrights",
            dependencies: ["Danger"]),
        .testTarget(
            name: "DangerNoCopyrightsTests",
-           dependencies: ["DangerNoCopyrights"]),
+           dependencies: ["DangerNoCopyrights", "DangerFixtures"]),
    ]
)
```

You want to be able to inject in a different DSL to your function somehow, let's avoid exposing our testing functions to
your consumers, edit your `DangerNoCopyrights.swift`:

```diff
import Danger
import Foundation

/// Public facing
public func checkForCopyrightHeaders() -> Void {
+     let danger = Danger()
+     checkForCopyrightHeaders(danger: danger)
+ }
+
+ /// Private function for facing
+ func checkForCopyrightHeaders(danger: DangerDSL) -> Void {<commit_msg>Update extending_danger_two.html.md<commit_after>---
title: Extending Danger extended
subtitle: Plugin engineering
layout: guide_sw
order: 0
blurb: Get your plugin tested
---

### Writing Tests

Danger Swift makes it easy for you to write tests, it includes a second library for importing into your tests. This
library includes a set of functions to get a set-up version of the Danger runtime in your tests.

Edit your `Package.swift` to add a reference to the two Danger libraries:

```diff
    ],
    targets: [
        // Targets are the basic building blocks of a package. A target can define a module or a test suite.
        // Targets can depend on other targets in this package, and on products in packages which this package depends on.
        .target(
            name: "DangerNoCopyrights",
            dependencies: ["Danger"]),
        .testTarget(
            name: "DangerNoCopyrightsTests",
-           dependencies: ["DangerNoCopyrights"]),
+           dependencies: ["DangerNoCopyrights", "DangerFixtures"]),
    ]
)
```

You want to be able to inject in a different DSL to your function somehow, let's avoid exposing our testing functions to
your consumers, edit your `DangerNoCopyrights.swift`:

```diff
import Danger
import Foundation

/// Public facing
public func checkForCopyrightHeaders() -> Void {
+     let danger = Danger()
+     checkForCopyrightHeaders(danger: danger)
+ }
+
+ /// Private function for testing
+ func checkForCopyrightHeaders(danger: DangerDSL) -> Void {
{'fraction_non_alphanumeric': 0.08324941255454851, 'fraction_numerical': 0.000671366230278617, 'mean_word_length': 3.3313953488372094, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2266776', 'n_tokens_mistral': 805, 'n_tokens_neox': 757, 'n_words': 349}