welltested 2.2.2 copy "welltested: ^2.2.2" to clipboard
welltested: ^2.2.2 copied to clipboard

discontinued

WelltestedAI is a Testing AI Pilot helping developers add and maintain tests as they code and deliver stable welltested apps to users.


mason logo


Welltested AI is a testing autopilot that automatically creates and maintains unit test coverage in your codebase, helping you deliver welltested apps to users.

welltested_demo

Setup #

⚙️ Configure API Key #

Please setup an account, and get your API Key. Welltested AI is completely free for individual developers.

Create a .env file at the root of your project, and add your API key received in the email.

WELLTESTED_API=YOUR_API_KEY

✅ Activate Dependency #

Add welltested_annotation in your pubspec.yaml along with mockito and build_runner as optional dev_dependencies.

dependencies:
  welltested_annotation: ^1.0.1
  
dev_dependencies:  

  //[optional] to generate mocks
  mockito:
  build_runner:

Then activate the welltested CLI globally:

dart pub global activate welltested

Note: You may also use welltested init to automatically install the required dependencies and setup the API Key configuration.

Quick Start - Unit Test #

1. Annotate for Testing #

Add the @Welltested() annotation to the classes and extensions whose methods you want to test or directly to the top level functions.

@Welltested()
class Auth {
    Future<void> logInUser() {...}
    Future<void> logOutUser() {...}
}

In the above case, welltested will generate unit tests for logInUser and logOutUser methods of Auth class.

2. Generate Unit Tests #

To generate unit tests for annotated classes, please run:

welltested generate unit

This takes a few minutes to complete and the generated tests can be found in the /test folder.

3. Save Unit Tests #

If you make adjustments to the generated tests, please save them by running the command:

welltested save unit

Note: Saving tests regularly helps welltested learn from your changes and improve the quality of future test generations.

Exclude Methods

By default, all methods in an annotated class are included for testing. To exclude any methods, add their names to the excludedMethods list in the Welltested annotation.

@Welltested(excludedMethods: ['logOutUser'])
class Auth {
    Future<void> logInUser() {...}
    Future<void> logOutUser() {...}
}

For example, here welltested will not generate unit tests for logOutUser method.

Custom Testcases

To specify custom testcases for any method, use @Testcases() annotation.

@Welltested()
class Auth {
    @Testcases(['Throws exception when email is empty'])
    Future<User> logInUser() {...}
}

Quick Start - Integration Test #

1. Create welltested.dart File #

In the project root directory, create a file integration-test/welltested.dart file. You will use this file to add your test flows and relevant test objects in config classes. Welltested will then use this information to generate the integration tests for you. The created file will look something like this:

// Example of WelltestedIntegrationTest config class that will test the login flow
 class LoginTests extends WelltestedIntegrationTest {
   @override
   String get setup => "Open the app";

   @override
   List<String> get testFlows => [
         'On login Screen, entering user@gmail.com/12345678 and logging in takes user to the main screen',
         'On login Screen, click the button \'Forgot Password?\' and verfiy that only mail textfield is present'
       ];

   @override
   List<Object> get testObjects => [main, MyApp, Login, MainScreen];
 }

// Example of WelltestedIntegrationTest config class that will test the chat navigation flow
 class ChatNavigationTest extends WelltestedIntegrationTest {
  @override
  String get setup => "Reach to Main Screen";

  @override
  List<String> get testFlows => [
        "On Main Screen, tap at the message icon in the bottom navigation bar to open the chat tab"
      ];

  @override
  List<Object> get testObjects => [MainScreen, Chats];
}

2. Generate Integration Tests #

To generate integration test for a specific test flow, please run:

welltested generate integration -c LoginTests -i 0

Here -c accepts the module name which contains the flow and setup instructions. In the above demonstrated welltested.dart file. LoginTests and ChatNavigationTest are modules name that you can pass.

Finally, -i takes index of the test flow for which you want to generate the test among the list of test flows added in the module. The above demonstrated command will run integration test only for the first test flow. i.e., On login Screen, entering user@gmail.com/12345678 and logging in takes user to the main screen

Note: Please note that the -i option is optional and can be omitted if necessary. However, it is not recommended by the to exclude the -i option.

3. Save Integration Tests #

To save specific test mentioned in module, please run:

welltested save integration -c LoginTests

Here, -c takes the name of the module whose generated test you want to save.

Note: Similar to unit testing. Saving tests regularly will help welltested learn from your changes and improve the quality of future test generations. It will also help welltested to adapt your programming style and build future tests based design patterns choices.

Developer Docs #

For detailed documentation, please read our Developer Docs.

NOTE #

The minimum supported Flutter SDK version is 2.5.0 with Dart SDK v2.14.0. Make sure to upgrade your project to the minimum supported Flutter and Dart SDK versions before using Welltested AI.

29
likes
90
points
677
downloads

Publisher

verified publisherwelltested.ai

Weekly Downloads

WelltestedAI is a Testing AI Pilot helping developers add and maintain tests as they code and deliver stable welltested apps to users.

Repository (GitHub)
View/report issues

Documentation

API reference

License

unknown (license)

Dependencies

analysis_server_lib, analyzer, ansi_escapes, args, azure_application_insights, crypto, http, path, source_gen, welltested_annotation, yaml

More

Packages that depend on welltested