Skip to content

Commit

Permalink
Separate targets for unit and integration tests
Browse files Browse the repository at this point in the history
  • Loading branch information
matus-tomlein committed Sep 28, 2023
1 parent 8d8489d commit 101d5bc
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 13 deletions.
17 changes: 15 additions & 2 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 @@ -25,21 +25,31 @@ jobs:
xcode-version: "13.2.1"
sdk: iphonesimulator15.2
destination: "platform=iOS Simulator,OS=15.2,name=iPhone 13"
target: IntegrationTests
- name: "xcodebuild (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: Tests
- name: "xcodebuild (macOS 12.1, Xcode 13.2.1)"
os: macos-12
xcode-version: "13.2.1"
sdk: macosx12.1
destination: "platform=OS X"
target: Tests
- name: "xcodebuild (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"
target: Tests
- name: "xcodebuild (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 +63,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 +85,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 @@ -27,7 +27,6 @@ class TestTrackEventsToMicro: XCTestCase {
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 101d5bc

Please sign in to comment.