Hello ~ I’m Milo! This is a complete series of interface test platform tutorials, hoping to learn with you, from 0 to 1 to build an open source platform. Welcome to pay attention to my public number test development pit goods, get the latest article tutorial!

review

In the last video we looked at soft deletion, a seemingly insignificant but serious problem. Now let’s fill in the hole.

The hole we buried before

In the use-case detail page, you can only add assertions, but there is no support for editing and deleting, or even the display page. Today we will fill in the hole:

Complete the edit and delete functions for this section.

Old rule

Before you finish, take a look at the current renderings:

It’s just a little page with a curd underneath the assertion TAB.

Backend changes

The reason for this section is that in the past, after adding/editing data, we requested the list interface once, which is equivalent to requesting it twice.

This time, we will change the direction and get the latest data directly after the request, and then integrate it into the existing table.

In fact, THE reason for doing so is that I have a large page, which contains a lot of information about case, involving multiple tables, and I don’t want to package a separate interface for local data refresh.

Let’s see what we can do!

Learn the mechanics of SqlAlchemy

SqlAchemy is a familiar ORM library. I found one feature during my use:

For example, if I create a new model, update it to db with session.add.

But now we need to get the latest data after insert into the database. Sqlalchemy will, by default, destroy the data that was inserted before, or it will not be destroyed, or the data will no longer exist after the session ends.

So we did a search on Baidu and found a way to keep the original data:

session.expunge(data)
Copy the code

Write the interface for the new assertion

First wait for the data to update with session.flush(). Refresh will help us get the ID after the insert.

Finally, we use the expunge method to keep the object and return it.

Write an interface to edit assertions

Editing is similar to adding, but since we don’t need to get the primary key ID, because we already have it, we just need expunge.

Write an interface to remove assertions

Because of the soft delete, we actually perform the update operation as well.

Added the ability to execute use cases

In fact, very simple, just call the previous interface. Take a look at the picture


At this point, 80 percent of the execution of a case is complete. There are still a lot of things to do:

  • The scheduled task executes the case
  • Use case variables/global variables should not currently be applied to assertions
  • Assertions do not support JSON comparisons, etc
  • Use case scoring system
  • User Operation Records
  • Workbench not complete
  • User profile Modification
  • User Management
  • 7 Niuyun/Ali Cloud OSS access
  • Other pre-condition types
  • postconditions

.


There’s a lot of that already, not to mention future ones:

  • The data factory

  • Precision testing and so on

    But then again, this platform wants to really make a complete platform from 0 to 1, slowly fill in the hole ~