Skip to content

Commit aa82f1c

Browse files
feat: parallel-run tests
1 parent a5c920c commit aa82f1c

36 files changed

Lines changed: 590 additions & 70 deletions

.gitignore

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,4 +37,7 @@ example/android/app/release
3737

3838
example/ios/Podfile.lock
3939
example/android/app/debug
40-
example/lib/backup.dart
40+
example/lib/backup.dart
41+
42+
# Test runner output
43+
test_results/

example/integration_test/device_id_test.dart

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,28 @@
11
import 'dart:convert';
2-
import 'dart:html';
32
import 'package:countly_flutter/countly_flutter.dart';
43
import 'package:flutter/foundation.dart';
54
import 'package:flutter_test/flutter_test.dart';
65
import 'package:integration_test/integration_test.dart';
76

87
import 'utils.dart';
8+
import 'web_utils_stub.dart' if (dart.library.html) 'web_utils.dart';
99

10-
/// Check if we can get stored queues from native side
10+
/// Web-only device ID change tests.
11+
/// On non-web platforms, a single placeholder test passes so the runner doesn't fail.
1112
void main() {
1213
IntegrationTestWidgetsFlutterBinding.ensureInitialized();
1314

1415
if (!kIsWeb) {
16+
testWidgets('device_id_test (web-only, skipped on native)', (WidgetTester tester) async {
17+
// This test suite is web-only. On native platforms, this placeholder passes.
18+
});
1519
return;
1620
}
21+
1722
group("Device ID change tests", () {
1823
tearDown(() async {
1924
await Countly.instance.halt();
20-
window.localStorage.clear();
25+
clearWebLocalStorage();
2126
});
2227
test("Check init time temp mode with setID", () async {
2328
CountlyConfig config = CountlyConfig(SERVER_URL, APP_KEY).setLoggingEnabled(true).enableTemporaryDeviceIDMode();

example/integration_test/networking_tests/addCustomNetworkRequestHeaders_test.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ void main() {
2626
},
2727
);
2828
// Initialize the SDK
29-
CountlyConfig config = CountlyConfig("http://0.0.0.0:8080", APP_KEY).enableManualSessionHandling().setLoggingEnabled(true);
29+
CountlyConfig config = CountlyConfig(TEST_SERVER_URL, APP_KEY).enableManualSessionHandling().setLoggingEnabled(true);
3030
config.setCustomNetworkRequestHeaders({"Initial-Header": "InitialValue"});
3131
await Countly.initWithConfig(config);
3232
await Future.delayed(const Duration(seconds: 1));

example/integration_test/networking_tests/request_timeout_duration_default_test.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ void main() {
1515
createServer(requestArray, delay: 3);
1616

1717
// Initialize SDK with default request timeout
18-
CountlyConfig config = CountlyConfig('http://0.0.0.0:8080', APP_KEY).enableManualSessionHandling().setLoggingEnabled(true); // Use default timeout
18+
CountlyConfig config = CountlyConfig(TEST_SERVER_URL, APP_KEY).enableManualSessionHandling().setLoggingEnabled(true); // Use default timeout
1919

2020
await Countly.initWithConfig(config);
2121

example/integration_test/networking_tests/request_timeout_duration_test.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ void main() {
1717
createServer(requestArray, delay: 3);
1818

1919
// Initialize SDK with a short request timeout
20-
CountlyConfig config = CountlyConfig('http://0.0.0.0:8080', APP_KEY).enableManualSessionHandling().setLoggingEnabled(true).setRequestTimeoutDuration(1); // Set timeout to 1 second
20+
CountlyConfig config = CountlyConfig(TEST_SERVER_URL, APP_KEY).enableManualSessionHandling().setLoggingEnabled(true).setRequestTimeoutDuration(1); // Set timeout to 1 second
2121

2222
await Countly.initWithConfig(config);
2323

example/integration_test/sbs_tests/SBS_000_base_test.dart

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ void main() {
1515
List<Map<String, List<String>>> requestArray = <Map<String, List<String>>>[];
1616
createServerWithConfig(requestArray, {});
1717
// Initialize the SDK
18-
CountlyConfig config = CountlyConfig('http://0.0.0.0:8080', APP_KEY).enableManualSessionHandling().setLoggingEnabled(true);
18+
CountlyConfig config = CountlyConfig(TEST_SERVER_URL, APP_KEY).enableManualSessionHandling().setLoggingEnabled(true);
1919
await Countly.initWithConfig(config);
2020

2121
await callAllFeatures();
@@ -24,6 +24,7 @@ void main() {
2424
List<String> EQ = await getEventQueue();
2525
expect(RQ.length, 0);
2626
expect(EQ.length, 0);
27+
deduplicateRequestArray(requestArray);
2728
validateRequestCounts({'events': 3, 'location': 1, 'crash': 2, 'begin_session': 1, 'consent': 0, 'end_session': 1, 'session_duration': 2, 'apm': 2, 'user_details': Platform.isIOS ? 2 : 1}, requestArray);
2829
validateInternalEventCounts({'orientation': 1, 'view': 6, 'nps': 1}, requestArray);
2930
validateImmediateCounts({'hc': 1, 'sc': 1, 'feedback': 1, 'queue': 2, 'ab': 1, 'ab_opt_out': 1, 'rc': 1}, requestArray);

example/integration_test/sbs_tests/SBS_200A_test.dart

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ void main() {
1919
});
2020

2121
// Initialize the SDK
22-
CountlyConfig config = CountlyConfig('http://0.0.0.0:8080', APP_KEY).enableManualSessionHandling().setLoggingEnabled(true);
22+
CountlyConfig config = CountlyConfig(TEST_SERVER_URL, APP_KEY).enableManualSessionHandling().setLoggingEnabled(true);
2323

2424
await Countly.initWithConfig(config);
2525
await Future.delayed(const Duration(seconds: 2));
@@ -33,7 +33,7 @@ void main() {
3333
await callAllFeatures(disableEnterContent: true);
3434
RQ = await getRequestQueueParsed();
3535
expect(RQ.length, 0);
36-
36+
deduplicateRequestArray(requestArray);
3737
validateRequestCounts({'first': 0, 'second': 1, 'events': Platform.isAndroid ? 3 : 2, 'location': 1, 'crash': 2, 'begin_session': 1, 'end_session': 1, 'session_duration': 2, 'apm': 2, 'user_details': Platform.isIOS ? 2 : 1, 'consent': 0}, requestArray);
3838
// validate that first request is deleted from the queue because of dort: 1
3939
validateInternalEventCounts({'orientation': 1, 'view': Platform.isAndroid ? 6 : 5, 'nps': 1}, requestArray); // 6 android

example/integration_test/sbs_tests/SBS_200B_test.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ void main() {
1717
});
1818

1919
// Initialize the SDK
20-
CountlyConfig config = CountlyConfig('http://0.0.0.0:8080', APP_KEY).enableManualSessionHandling().setLoggingEnabled(true);
20+
CountlyConfig config = CountlyConfig(TEST_SERVER_URL, APP_KEY).enableManualSessionHandling().setLoggingEnabled(true);
2121

2222
await Countly.initWithConfig(config);
2323
await Future.delayed(const Duration(seconds: 2));

example/integration_test/sbs_tests/SBS_200C_test.dart

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,32 +16,33 @@ void main() {
1616
createServerWithConfig(requestArray, {
1717
'v': 1,
1818
't': 1750748806695,
19-
'c': {'networking': false, 'cr': true, 'rqs': 5, 'sui': 10}
19+
'c': {'networking': false, 'cr': true, 'rqs': 5, 'sui': 10},
2020
});
2121

2222
setServerConfig({
2323
'v': 1,
2424
't': 1750748806695,
25-
'c': {'networking': false, 'cr': true, 'rqs': 5, 'sui': 10}
25+
'c': {'networking': false, 'cr': true, 'rqs': 5, 'sui': 10},
2626
});
2727

2828
// Initialize the SDK
29-
CountlyConfig config = CountlyConfig('http://0.0.0.0:8080', APP_KEY).setLoggingEnabled(true).setDeviceId('device_id_200C');
29+
CountlyConfig config = CountlyConfig(TEST_SERVER_URL, APP_KEY).setLoggingEnabled(true).setDeviceId('device_id_200C');
3030

3131
await Countly.initWithConfig(config);
3232
await Future.delayed(const Duration(seconds: 2));
3333

3434
await callAllFeatures(disableConsentCall: true);
3535

3636
// Validate that networking is disabled and no requests are sent
37+
deduplicateRequestArray(requestArray);
3738
expect(requestArray.length, 1); // only SC request should be sent
3839
validateImmediateCounts({'sc': 1}, requestArray);
3940
requestArray.clear(); // clear requestArray to validate the next requests
4041

4142
// Validate that consent is required and not given and all called features are not created a request
4243
List<Map<String, List<String>>> rq = await getRequestQueueParsed();
4344
validateRequestCounts({'consent': 1, 'location': 1}, rq);
44-
Map<String, dynamic> expectedConsent = {'push': false, 'views': false, 'attribution': false, 'content': false, 'users': false, 'feedback': false, 'apm': false, 'location': false, 'remote-config': false, 'sessions': false, 'crashes': false, 'events': false};
45+
Map<String, dynamic> expectedConsent = {'push': false, 'views': false, 'attribution': false, 'content': false, 'users': false, 'feedback': false, 'apm': false, 'location': false, 'remote-config': false, 'sessions': false, 'crashes': false, 'events': false, 'metrics': false};
4546

4647
if (Platform.isAndroid) {
4748
expectedConsent['scrolls'] = false; // Android has scrolls, content, star-rating, clicks consents extra
@@ -81,7 +82,7 @@ void main() {
8182
expect(await getServerConfig(), {
8283
'v': 1,
8384
't': 1750748806695,
84-
'c': {'networking': false, 'cr': true, 'rqs': 5, 'sui': 10}
85+
'c': {'networking': false, 'cr': true, 'rqs': 5, 'sui': 10},
8586
});
8687
});
8788
}

example/integration_test/sbs_tests/SBS_200D_test.dart

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ void main() {
1919
'c': {'st': false, 'cet': false, 'vt': false, 'eqs': 5, 'lt': false, 'crt': false, 'bom_at': 5, 'bom_d': 30, 'bom_rqp': 0.001, 'bom_ra': 1}
2020
});
2121
// Initialize the SDK
22-
CountlyConfig config = CountlyConfig('http://0.0.0.0:8080', APP_KEY).enableManualSessionHandling().setLoggingEnabled(true);
22+
CountlyConfig config = CountlyConfig(TEST_SERVER_URL, APP_KEY).enableManualSessionHandling().setLoggingEnabled(true);
2323
await Countly.initWithConfig(config);
2424

2525
await callAllFeatures();
@@ -28,6 +28,7 @@ void main() {
2828
List<String> EQ = await getEventQueue();
2929
expect(RQ.length, 0);
3030
expect(EQ.length, 0);
31+
deduplicateRequestArray(requestArray);
3132
validateRequestCounts({'events': 1, 'location': 1, 'crash': 0, 'begin_session': 0, 'consent': 0, 'end_session': 0, 'session_duration': 0, 'apm': 2, 'user_details': Platform.isIOS ? 2 : 1}, requestArray);
3233
validateInternalEventCounts({'nps': 1}, requestArray);
3334
validateImmediateCounts({'hc': 1, 'sc': 1, 'feedback': 1, 'queue': 2, 'ab': 1, 'ab_opt_out': 1, 'rc': 1}, requestArray);
@@ -43,7 +44,7 @@ void main() {
4344
EQ = await getEventQueue();
4445
expect(EQ.length, 0); // validate that event queue is cleared when hit the limit and recording internal events are not affected by the custom event tracking disablement
4546
await Future.delayed(const Duration(seconds: 2));
46-
47+
deduplicateRequestArray(requestArray);
4748
validateInternalEventCounts({'nps': 1, 'star_rating': 3, 'orientation': 2}, requestArray);
4849

4950
expect(await getServerConfig(), {

0 commit comments

Comments
 (0)