Skip to content

Commit

Permalink
Separate targets for unit and integration tests (#831)
Browse files Browse the repository at this point in the history
  • Loading branch information
matus-tomlein authored Oct 2, 2023
1 parent 1f76199 commit f02d952
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 19 deletions.
26 changes: 20 additions & 6 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ jobs:
runs-on: macos-11
strategy:
matrix:
platform: [ios, osx, tvos, watchos]
platform: [ios, ios, osx, tvos, watchos]
steps:
- uses: actions/checkout@v3
- name: Lint Podspec
Expand All @@ -18,28 +18,39 @@ jobs:
name: ${{ matrix.name }}
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
include:
- name: "xcodebuild (iOS 15.2, Xcode 13.2.1)"
- name: "Integration (iOS 15.2, Xcode 13.2.1)"
os: macos-12
xcode-version: "13.2.1"
sdk: iphonesimulator15.2
destination: "platform=iOS Simulator,OS=15.2,name=iPhone 13"
target: IntegrationTests
- name: "Unit (iOS 15.2, Xcode 13.2.1)"
os: macos-12
xcode-version: "13.2.1"
sdk: iphonesimulator15.2
destination: "platform=iOS Simulator,OS=15.2,name=iPhone 13"
- name: "xcodebuild (macOS 12.1, Xcode 13.2.1)"
target: Tests
- name: "Unit (macOS 12.1, Xcode 13.2.1)"
os: macos-12
xcode-version: "13.2.1"
sdk: macosx12.1
destination: "platform=OS X"
- name: "xcodebuild (watchOS 8.3, Xcode 13.2.1)"
target: Tests
- name: "Unit (watchOS 8.3, Xcode 13.2.1)"
os: macos-12
xcode-version: "13.2.1"
sdk: watchos8.3
destination: "platform=watchOS Simulator,OS=8.3,name=Apple Watch Series 7 - 45mm"
- name: "xcodebuild (tvOS 15.2, Xcode 13.2.1)"
target: Tests
- name: "Unit (tvOS 15.2, Xcode 13.2.1)"
os: macos-12
xcode-version: "13.2.1"
sdk: appletvsimulator15.2
destination: "platform=tvOS Simulator,OS=15.2,name=Apple TV"
target: Tests
steps:
- name: Checkout
uses: actions/checkout@v3
Expand All @@ -53,13 +64,15 @@ jobs:
key: ${{ runner.os }}-micro

- name: Get micro
if: steps.cache-micro.outputs.cache-hit != 'true'
if: steps.cache-micro.outputs.cache-hit != 'true' && matrix.target == 'IntegrationTests'
run: curl -o micro.jar -L https://github.com/snowplow-incubator/snowplow-micro/releases/download/micro-1.7.0/snowplow-micro-1.7.0.jar

- name: Run Micro in background
if: matrix.target == 'IntegrationTests'
run: java -jar micro.jar &

- name: Wait on Micro endpoint
if: matrix.target == 'IntegrationTests'
timeout-minutes: 2
run: while ! nc -z '0.0.0.0' 9090; do sleep 1; done
# -- Micro --
Expand All @@ -73,6 +86,7 @@ jobs:
-scheme SnowplowTracker \
-sdk "${{ matrix.sdk }}" \
-destination "${{ matrix.destination }}" \
-only-testing ${{ matrix.target }} \
clean test | xcpretty
build_objc_demo_app:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,14 @@ class TestTrackEventsToMicro: XCTestCase {

override func setUp() {
super.setUp()

let trackerConfig = TrackerConfiguration()
.logLevel(.debug)

tracker = Snowplow.createTracker(namespace: "testMicro",
network: NetworkConfiguration(endpoint: Micro.endpoint))!
tracker = Snowplow.createTracker(namespace: "testMicro-" + UUID().uuidString,
network: NetworkConfiguration(endpoint: Micro.endpoint),
configurations: [trackerConfig])!

Micro.setUpMockerIgnores()
wait(for: [Micro.reset()], timeout: Micro.timeout)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@

import Foundation
import XCTest
import Mocker

class Micro {

Expand All @@ -26,14 +25,6 @@ class Micro {
static let endpoint = "http://0.0.0.0:9090"
#endif

class func setUpMockerIgnores() {
Mocker.ignore(URL(string: "\(endpoint)/micro/good")!)
Mocker.ignore(URL(string: "\(endpoint)/micro/reset")!)
Mocker.ignore(URL(string: "\(endpoint)/micro/all")!)
Mocker.ignore(URL(string: "\(endpoint)/com.snowplowanalytics.snowplow/tp2")!)
Mocker.ignore(URL(string: "\(endpoint)/i")!)
}

class func reset() -> XCTestExpectation {
let expectation = XCTestExpectation(description: "Reset Micro")
let url = URLRequest(url: URL(string: "\(endpoint)/micro/reset")!)
Expand Down
8 changes: 7 additions & 1 deletion Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,13 @@ let package = Package(
"SnowplowTracker",
"Mocker"
],
path: "Tests")
path: "Tests"),
.testTarget(
name: "IntegrationTests",
dependencies: [
"SnowplowTracker"
],
path: "IntegrationTests")
]
)
#if swift(>=5.6)
Expand Down

0 comments on commit f02d952

Please sign in to comment.