1

项目中用了ES6的继承。随着开发人员多了之后发现,有些情况下改动了父类,忘记测试子类是否可以工作了。可能开发人员不知道这个类是不是被其他类继承了。

我想问的是,有没有一种工具可以清晰的看到项目中的类的继承关系?这样就比较方便的看到当前这个类是不是被子类继承了,改动的时候就会测试下子类。

谢谢。

查看全部 5 个回答

1

来自外国友人 bug-a-lot 的回复:

Unit Tests

Unit test your code! If a superclass changes behavior, it will likely
break a unit test, so you know you messed up and you know to correct
the offending subclasses.

If it broke functionality in your application, but not one of your
unit tests, then your unit test coverage is not good enough, or you've
missed some scenarios.

That's the number one thing you should do before any kind of
refactoring! Unit test, unit test, and again unit test!

Text Search

If you're using any fancy IDEs you could search through javascript
files for something like "extends MyChangedSuperClasss", assuming you
colleagues don't use an arbitrary number of spaces between the keyword
and the class name.

If you're not using a fancy IDE try to find a file manager that offers
text search functions.

How to check the inheritance relationship of ES6 classes in my project? - stack overflow