私は現在、それぞれテスト付きの2つの関数を持っています。
function A(x) {
// do A things
return Aresults;
}
function testA() {
// this put A through its test and make sure it does what it's supposed to
}
と
function B(x) {
// do B things which involve using A
return Bresults;
}
function testB() {
// this put B through its test and make sure it does what it's supposed to
}
私は今、Aの唯一の使用法がBであることに気づきました。そこで、コードを分離して保護するためにリファクタリングしたいと思います。
function B(x) {
function A(x) {
// do A things
return Aresults;
}
// do B things which involve using A
return Bresults;
}
function testB() {
// this put B through its test and make sure it does what it's supposed to
}
私の質問は、AがBのクローズドオーバー関数になったので、どうすればAのテストを追加できるかということです。つまり、私のtestA関数はどこに行きますか?