anchor.diff:    });
   
     test('class with final fields', () async {
  -    var element = await _getClassForCodeString('FinalFields');
  -    var generateResult = await _generator.generate(element, null);
  +    var generateResult = await _runForElementNamed('FinalFields');
       expect(generateResult, contains("Map<String, dynamic> toJson()"));
     });
   
     test('unannotated classes no-op', () async {
  -    var element = await _getClassForCodeString('NoAnnotation');
  -    var output = _generator.generate(element, null);
  +    var output = await _runForElementNamed('NoAnnotation');
   
       expect(output, isNull);
     });
   
     group('valid inputs', () {
       test('class with no fields', () async {
  -      var element = await _getClassForCodeString('Person');
  -      var output = await _generator.generate(element, null);
  +      var output = await _runForElementNamed('Person');
   
         expect(output, isNotNull);
   
  
positive.code: void main() {
    group('non-classes', () {
      test('const field', () async {
        var element = await _getClassForCodeString('theAnswer');
  
        expect(
            _generator.generate(element, null),
            throwsInvalidGenerationSourceError(
                'Generator cannot target `const dynamic theAnswer`.',
                'Remove the JsonSerializable annotation from `const dynamic theAnswer`.'));
      });
  
      test('method', () async {
        var element = await _getClassForCodeString('annotatedMethod');
  
        expect(
            _generator.generate(element, null),
            throwsInvalidGenerationSourceError(
                'Generator cannot target `annotatedMethod`.',
                'Remove the JsonSerializable annotation from `annotatedMethod`.'));
      });
    });
  
    group('unknown types', () {
      test('in constructor arguments', () async {
        var element = await _getClassForCodeString('UnknownCtorParamType');
  
        expect(
            _generator.generate(element, null),
            throwsInvalidGenerationSourceError(
                'At least one constructor argument has an invalid type: `number`.',
                'Check names and imports.'));
      });
  
      test('in fields', () async {
        var element = await _getClassForCodeString('UnknownFieldType');
  
        expect(
            _generator.generate(element, null),
            throwsInvalidGenerationSourceError(
                'At least one field has an invalid type: `number`.',
                'Check names and imports.'));
  
negative.code: 
    group('unserializable types', () {
      test('for toJson', () async {
        expect(
            _runForElementNamed('NoSerializeFieldType'),
            throwsInvalidGenerationSourceError(
                'Could not generate `toJson` code for `Stopwatch watch`.',
                'Make sure all of the types are serializable.'));
      });
  
      test('for fromJson', () async {
        expect(
            _runForElementNamed('NoDeserializeFieldType'),
            throwsInvalidGenerationSourceError(
                'Could not generate fromJson code for `Stopwatch watch`.',
                'Make sure all of the types are serializable.'));
      });
  
      test('for toJson in Map key', () async {
        expect(
            _runForElementNamed('NoSerializeBadKey'),
            throwsInvalidGenerationSourceError(
                'Could not generate `toJson` code for `Map<int, DateTime> intDateTimeMap`.',
                'Make sure all of the types are serializable.'));
      });
  
      test('for fromJson', () async {
        expect(
            _runForElementNamed('NoDeserializeBadKey'),
            throwsInvalidGenerationSourceError(
                'Could not generate fromJson code for `Map<int, DateTime> intDateTimeMap`.',
                'Make sure all of the types are serializable.'));
  