Skip to content

Commit

Permalink
pruebas unitarias final
Browse files Browse the repository at this point in the history
  • Loading branch information
Jeisson Andres Palacio Velasquez committed Oct 11, 2020
1 parent d05ac3f commit 466631d
Show file tree
Hide file tree
Showing 9 changed files with 157 additions and 154 deletions.
1 change: 1 addition & 0 deletions pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ dependencies:




dev_dependencies:
flutter_driver:
sdk: flutter
Expand Down
1 change: 1 addition & 0 deletions report.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
[{"description":"","id":"counter button","keyword":"Feature","line":1,"name":"Counter Button","uri":".\\test_driver\\features\\counter_button.feature","elements":[{"keyword":"Scenario","type":"scenario","id":"counter button;user taps on counter button","name":"User taps on counter button","description":"","line":7,"steps":[{"keyword":"Given ","name":"the user is at the counter dashboard","line":8,"match":{"location":".\\test_driver\\features\\counter_button.feature:8"},"result":{"status":"passed","duration":20000000}},{"keyword":"And ","name":"the counter value is at 0","line":9,"match":{"location":".\\test_driver\\features\\counter_button.feature:9"},"result":{"status":"failed","duration":0,"error_message":"GherkinStepNotDefinedException: Step definition not found for text:\n\n 'And the counter value is at 0'\n\n File path: .\\test_driver\\features\\counter_button.feature#8\n Line: And the counter value is at 0\n\n ---------------------------------------------\n\n You must implement the step like below and add the class to the 'stepDefinitions' property in your configuration:\n\n /// The 'Given' class prefix can be replaced with 'Then', 'When' 'And' or 'But'\n /// All classes can take up to 5 input parameters. With more, you should probably use a table.\n /// For example: `When4<String, bool, int, num>`\n /// You can also specify the type of world context you want\n /// `When4WithWorld<String, bool, int, num, MyWorld>`\n class Given_And_the_counter_value_is_at_0 extends Given1<String> {\n @override\n RegExp get pattern => RegExp(r\"the counter value is at 0\");\n\n @override\n Future<void> executeStep(String input1) async {\n // If the step is \"Given I do a 'windy pop'\"\n // in this example, input1 would equal 'windy pop'\n\n // your code...\n }\n }\n \n\n#0 FeatureFileRunner._matchStepToExecutableStep (package:gherkin/src/feature_file_runner.dart:390:7)\n#1 FeatureFileRunner._runStep (package:gherkin/src/feature_file_runner.dart:311:20)\n#2 _rootRunUnary (dart:async/zone.dart:1198:47)\n#3 _CustomZone.runUnary (dart:async/zone.dart:1100:19)\n#4 _FutureListener.handleValue (dart:async/future_impl.dart:143:18)\n#5 Future._propagateToListeners.handleValueCallback (dart:async/future_impl.dart:696:45)\n#6 Future._propagateToListeners (dart:async/future_impl.dart:725:32)\n#7 Future._completeWithValue (dart:async/future_impl.dart:529:5)\n#8 _AsyncAwaitCompleter.complete (dart:async-patch/async_patch.dart:40:15)\n#9 _completeOnAsyncReturn (dart:async-patch/async_patch.dart:311:13)\n#10 AggregatedReporter.onStepStarted (package:gherkin/src/reporters/aggregated_reporter.dart)\n#11 _rootRunUnary (dart:async/zone.dart:1198:47)\n#12 _CustomZone.runUnary (dart:async/zone.dart:1100:19)\n#13 _FutureListener.handleValue (dart:async/future_impl.dart:143:18)\n#14 Future._propagateToListeners.handleValueCallback (dart:async/future_impl.dart:696:45)\n#15 Future._propagateToListeners (dart:async/future_impl.dart:725:32)\n#16 Future._completeWithValue (dart:async/future_impl.dart:529:5)\n#17 _AsyncAwaitCompleter.complete (dart:async-patch/async_patch.dart:40:15)\n#18 _completeOnAsyncReturn (dart:async-patch/async_patch.dart:311:13)\n#19 AggregatedReporter._invokeReporters (package:gherkin/src/reporters/aggregated_reporter.dart)\n#20 _rootRunUnary (dart:async/zone.dart:1198:47)\n#21 _CustomZone.runUnary (dart:async/zone.dart:1100:19)\n#22 _FutureListener.handleValue (dart:async/future_impl.dart:143:18)\n#23 Future._propagateToListeners.handleValueCallback (dart:async/future_impl.dart:696:45)\n#24 Future._propagateToListeners (dart:async/future_impl.dart:725:32)\n#25 Future._completeWithValue (dart:async/future_impl.dart:529:5)\n#26 _AsyncAwaitCompleter.complete (dart:async-patch/async_patch.dart:40:15)\n#27 _completeOnAsyncReturn (dart:async-patch/async_patch.dart:311:13)\n#28 AggregatedReporter.onStepStarted.<anonymous closure> (package:gherkin/src/reporters/aggregated_reporter.dart)\n#29 _rootRunUnary (dart:async/zone.dart:1198:47)\n#30 _CustomZone.runUnary (dart:async/zone.dart:1100:19)\n#31 _FutureListener.handleValue (dart:async/future_impl.dart:143:18)\n#32 Future._propagateToListeners.handleValueCallback (dart:async/future_impl.dart:696:45)\n#33 Future._propagateToListeners (dart:async/future_impl.dart:725:32)\n#34 Future._completeWithValue (dart:async/future_impl.dart:529:5)\n#35 Future._asyncCompleteWithValue.<anonymous closure> (dart:async/future_impl.dart:567:7)\n#36 _rootRun (dart:async/zone.dart:1190:13)\n#37 _CustomZone.run (dart:async/zone.dart:1093:19)\n#38 _CustomZone.runGuarded (dart:async/zone.dart:997:7)\n#39 _CustomZone.bindCallbackGuarded.<anonymous closure> (dart:async/zone.dart:1037:23)\n#40 _microtaskLoop (dart:async/schedule_microtask.dart:41:21)\n#41 _startMicrotaskLoop (dart:async/schedule_microtask.dart:50:5)\n#42 _runPendingImmediateCallback (dart:isolate-patch/isolate_patch.dart:118:13)\n#43 _RawReceivePortImpl._handleMessage (dart:isolate-patch/isolate_patch.dart:169:5)"}}]}]}]
78 changes: 41 additions & 37 deletions test/calculator_screen_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2,67 +2,71 @@ import 'package:flutter/material.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:project_test_unit/screens/calculator_screen.dart';

main(){

main() {

testWidgets("Prueba de pantalla calcular alquiler", (WidgetTester test) async{

final MaterialApp app = MaterialApp(

home: Scaffold(body: CalculatorScreen(),),
);

testWidgets("Prueba pantalla calcular alquler", (WidgetTester test)async{

await test.pumpWidget(app);
final datainput = find.byKey(Key("datapicker"));
await test.tap(datainput);
await test.pump(new Duration(milliseconds: 50));
await test.tap(find.text("15"));
await test.pump();
await test.tap(find.text("24"));
await test.pump();
await test.longPress(find.text("OK"));
await test.pump();
final MaterialApp app = MaterialApp(
home: Scaffold(body: CalculatorScreen(),)
);


expect(find.text("09/15/2020-09/24/2020"), findsOneWidget);

var dropdown = find.byKey(Key("DropdownPrincipal"));
await test.tap(dropdown);
await test.pump(new Duration(milliseconds: 50));
await test.pumpWidget(app);

final datainput = find.byKey(Key("datapicker"));
await test.tap(datainput);
await test.pump(new Duration(milliseconds: 50));

await test.tap(find.text("15"));
await test.pump();

await test.longPress(find.text("Automatico").at(1));
await test.tap(find.text("24"));
await test.pump();

await test.pump();
await test.longPress(find.text("OK"));
await test.pump();

final result = dropdown.evaluate().single.widget as DropdownButton;
expect(result.value,equals('2000'));
expect(find.text("09/15/2020-09/24/2020"),findsOneWidget);

var dropdown = find.byKey(Key("DropdownPrincipal"));
await test.tap(dropdown);

await test.tap(find.text("Todo riesgo"));
await test.pump(new Duration(microseconds: 50));
await test.tap(find.text("Calcular"));
await test.pump();
await test.pump(new Duration(milliseconds: 50));

final resultado = find.byKey(Key("test"));
final data = resultado.evaluate().single.widget as Text;

expect(data.data, equals("\$118000"));
await test.longPress(find.text("Automatico").at(1));

await test.pump();

final result = dropdown.evaluate().single.widget as DropdownButton;

expect(result.value,equals('2000'));

await test.tap(find.text("Todo riesgo"));
await test.pump(new Duration(microseconds: 50));
await test.tap(find.text("Calcular"));

await test.pump();

final resultado = find.byKey(Key('test'));
final info = resultado.evaluate().single.widget as Text;

expect(info.data,equals("\$118000"));










});


});



}
}
58 changes: 19 additions & 39 deletions test/process_logic_test.dart
Original file line number Diff line number Diff line change
@@ -1,67 +1,47 @@



import 'package:flutter_test/flutter_test.dart';
import 'package:project_test_unit/bloc/logic.dart';


main(){

group("Grupo de pruebas process logic",(){
group("Grupo de pruebas de process logic", (){

ProcessesLogic process;

setUpAll((){

process = new ProcessesLogic();

});
setUpAll((){

process = new ProcessesLogic();

test("Prueba de calcular renta", (){

// Act

int result = process.calculateRent(4, 2000, 120000);
});


// Asssert
test("Prueba calcular renta", (){

expect(result, 128000);
int result = process.calculateRent(4, 2000, 120000);


expect(result,128000);


});

test("Calcular palindromo correcto", (){


// Act

test("Calcular palindromo",(){

bool result = process.calculatePalindromo(292);
expect(result, true);


expect(result,true);

});


test("Calcular Palindromo incorrecto",(){

// Act
bool result = process.calculatePalindromo(153);

// Assert

expect(result, false);


});


test("Generar excepcion", (){

expect(()=> process.calculatePalindromo(1), throwsA(predicate((e)=> e is ArgumentError && e.message == 'This is a test exception')));

});

test("Generar exepcion",(){

expect(()=>process.calculatePalindromo(1),throwsA(predicate((e)=>e is ArgumentError && e.message == 'This is a test exception')));

});


});
Expand Down
23 changes: 10 additions & 13 deletions test/suma_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2,24 +2,21 @@ import 'package:flutter_test/flutter_test.dart';
import 'package:project_test_unit/model/suma.dart' as addTwoNumbers;


main() {

test("Prueba de suma", (){

// Arragen
main(){

const a = 2;
const b = 3;
/// Arrage
const a = 2;
const b = 3;

// Act

int result = addTwoNumbers.addTwoNumbers(a, b);

// Assert
expect(result==5, isTrue);

/// act
int result = addTwoNumbers.addTwoNumbers(a, b);

/// assert
///
});
expect(5, equals(5));


}
33 changes: 33 additions & 0 deletions test/top_menu.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
import 'package:flutter/material.dart';
import 'package:flutter_svg/flutter_svg.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:project_test_unit/widgets/top_menu.dart';

main() {

final MaterialApp app = MaterialApp(
home: Scaffold(
body: HomeHeader()
),

);


testWidgets("Prueba Widget top menu", (WidgetTester test) async{

await test.pumpWidget(app);
final imagenCar = find.byKey(Key('assets/icons/car2.svg'));
final image = imagenCar.evaluate().single.widget as SvgPicture;

expect((image.pictureProvider as ExactAssetImage).assetName, equals('assets/icons/car2.svg'));
expect(find.text("Deportivo"), findsOneWidget);
expect(find.byType(ListView),findsOneWidget);




});



}
31 changes: 0 additions & 31 deletions test/top_meu_test.dart

This file was deleted.

11 changes: 7 additions & 4 deletions test_driver/app.dart
Original file line number Diff line number Diff line change
@@ -1,9 +1,12 @@
import 'package:flutter_driver/driver_extension.dart';
import 'package:project_test_unit/main.dart' as app;

void main() {
enableFlutterDriverExtension();
app.main();


void main(){

enableFlutterDriverExtension();
app.main();



}
Loading

0 comments on commit 466631d

Please sign in to comment.