html报告期间python coverage错误(NoSource:无代码源:)

时间:2019-09-04 08:12:51

标签: python windows windows-10 python-unittest coverage.py

我在报告html覆盖率时遇到以下错误。

Widget _renderList(BuildContext context) {
    if (this.todos.length == 0) {
      return Text(
          'You have no Todos yet. Create one by pressing the + button below');
    }

    return ListView.builder(
      itemCount: this.todos.length,
      itemBuilder: (BuildContext , int index) {
        return TodoListItem(this.todos[index].id, this.sortTodos);
      },
      shrinkWrap: false,
    );
  }

但是,该目录存在,并且我具有该权限:

void sortTodos() {
    this.setState(() {
      this.todos = Todo.sortTodosChronologically(todos);
    });
  }

请注意,我可以在终端上打印覆盖率报告:

class TodoListItem extends StatefulWidget {
  final int todoId;
  final Function() sortTodos;

  TodoListItem(this.todoId, this.sortTodos);

  @override
  createState() => _TodoListItemState(this.todoId);
}

class _TodoListItemState extends State<TodoListItem> {
  final int todoId;
  Todo todo = Todo.blank();

  _TodoListItemState(this.todoId);

  @override
  void initState() {
    super.initState();
    loadData();
  }

@override
Widget build(BuildContext context) {
    return Column(
      mainAxisAlignment: MainAxisAlignment.center,
      crossAxisAlignment: CrossAxisAlignment.start,
      children: <Widget>[
        IconButton(
          icon: Icon(
            Icons.check,
            color: Colors.indigo,
          ),
          onPressed: () => TodoService.completeTodo(this.todo.id).then(
            (Todo todo) {
              this.setState(() {
                this.todo = todo;
              });
              widget.sortTodos();
            },
          ).catchError(
            (error) => errorSnackBar(context, error),
          ),
        ),
      ],
    );
  }

如何生成html报告?

1 个答案:

答案 0 :(得分:1)

您使用coverage html生成HTML报告。