Angular try-and-catch场景的角度测试用例
我有下面的函数Angular try-and-catch场景的角度测试用例,angular,unit-testing,testcase,angular-test,Angular,Unit Testing,Testcase,Angular Test,我有下面的函数InitializeNetion(),在这里我初始化并设置了一个连接。 另外,我还有另一个函数showOtherInformation(),在其中,我确保在编写函数主体之前已设置好连接。 我想为它编写测试用例 initializeConnetion() { try { if(!this.connection) { this.connection = (window as any).parent.connectionFramework;
InitializeNetion()
,在这里我初始化并设置了一个连接。
另外,我还有另一个函数showOtherInformation()
,在其中,我确保在编写函数主体之前已设置好连接。
我想为它编写测试用例
initializeConnetion() {
try {
if(!this.connection) {
this.connection = (window as any).parent.connectionFramework;
this.metaInfo = this.connection.getMetaInfo();
}
} catch(error) {
connectionFailed(error, 'Could Initialize connection');
}
}
showOtherInformation() {
try {
initializeConnetion();
if(this.connection) {
this.connection.showOtherInfo('Data to be shown', {visibility: true});
}
} catch(error) {
connectionFailed(error, 'Could Initialize connection');
}
}