Skip to content
This repository was archived by the owner on Jan 14, 2025. It is now read-only.

Rename runReflectiveTests -> defineReflectiveTests. #4

Merged
merged 1 commit into from
Apr 22, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
.DS_Store
.idea
.pub/
.project
.settings/
build/
packages
Expand Down
12 changes: 6 additions & 6 deletions lib/test_reflective_loader.dart
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import 'dart:async';
import 'package:unittest/unittest.dart';

/**
* Runs test methods existing in the given [type].
* Define tests using methods existing in the given [type].
*
* Methods with names starting with `test` are run using [test] function.
* Methods with names starting with `solo_test` are run using [solo_test] function.
Expand All @@ -26,13 +26,13 @@ import 'package:unittest/unittest.dart';
* method invocation. If method returns [Future] to test some asyncronous
* behavior, then `tearDown` will be invoked in `Future.complete`.
*/
void runReflectiveTests(Type type) {
void defineReflectiveTests(Type type) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I know I suggested defineReflectiveTests, but another name to consider would be reflectiveTests. It follows the pattern of the test library, where the methods used to define the entities have are just the name of the entity. Very passive, like group or test. So reflectiveTests would be in keeping with that.

That said, I think defineReflectiveTests or reflectiveTests is an improvement over runReflectiveTests in terms of naming what it does, so whichever you prefer.

ClassMirror classMirror = reflectClass(type);
if (!classMirror.metadata.any((InstanceMirror annotation) =>
annotation.type.reflectedType == ReflectiveTest)) {
annotation.type.reflectedType == ReflectiveTest)) {
String name = MirrorSystem.getName(classMirror.qualifiedName);
throw new Exception('Class $name must have annotation "@reflectiveTest" '
'in order to be run by runReflectiveTests.');
'in order to be run by runReflectiveTests.');
}
String className = MirrorSystem.getName(classMirror.simpleName);
group(className, () {
Expand Down Expand Up @@ -102,8 +102,8 @@ Future _runFailingTest(ClassMirror classMirror, Symbol symbol) {
_runTest(ClassMirror classMirror, Symbol symbol) {
InstanceMirror instanceMirror = classMirror.newInstance(new Symbol(''), []);
return _invokeSymbolIfExists(instanceMirror, #setUp)
.then((_) => instanceMirror.invoke(symbol, []).reflectee)
.whenComplete(() => _invokeSymbolIfExists(instanceMirror, #tearDown));
.then((_) => instanceMirror.invoke(symbol, []).reflectee)
.whenComplete(() => _invokeSymbolIfExists(instanceMirror, #tearDown));
}

/**
Expand Down
2 changes: 1 addition & 1 deletion pubspec.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
name: test_reflective_loader
version: 0.0.2
version: 0.0.3
description: Support for discovering tests and test suites using reflection.
author: Dart Team <[email protected]>
homepage: https://github.com/dart-lang/test_reflective_loader
Expand Down