Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: include isTestSetup and TestSetup #363

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
6 changes: 4 additions & 2 deletions src/tests/asyncTests.ts
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ export class AsyncTests {
throw new Error(nls.localize('invalidTestRunIdErr', testRunId));
}

const testRunSummaryQuery = `SELECT AsyncApexJobId, Status, ClassesCompleted, ClassesEnqueued, MethodsEnqueued, StartTime, EndTime, TestTime, UserId FROM ApexTestRunResult WHERE AsyncApexJobId = '${testRunId}'`;
const testRunSummaryQuery = `SELECT AsyncApexJobId, Status, ClassesCompleted, ClassesEnqueued, MethodsEnqueued, StartTime, EndTime, TestTime, TestSetupTime, UserId FROM ApexTestRunResult WHERE AsyncApexJobId = '${testRunId}'`;

progress?.report({
type: 'FormatTestResultProgress',
Expand Down Expand Up @@ -232,6 +232,7 @@ export class AsyncTests {
testStartTime: formatStartTime(testRunSummary.StartTime, 'ISO'),
testExecutionTimeInMs: testRunSummary.TestTime ?? 0,
testTotalTimeInMs: testRunSummary.TestTime ?? 0,
testSetupTime: testRunSummary.TestSetupTime ?? 0,
commandTimeInMs: getCurrentTime() - commandStartTime,
hostname: this.connection.instanceUrl,
orgId: this.connection.getAuthInfoFields().orgId,
Expand Down Expand Up @@ -285,7 +286,7 @@ export class AsyncTests {
): Promise<ApexTestResult[]> {
let apexTestResultQuery = 'SELECT Id, QueueItemId, StackTrace, Message, ';
apexTestResultQuery +=
'RunTime, TestTimestamp, AsyncApexJobId, MethodName, Outcome, ApexLogId, ';
'RunTime, TestTimestamp, AsyncApexJobId, MethodName, Outcome, ApexLogId, IsTestSetup, ';
apexTestResultQuery +=
'ApexClass.Id, ApexClass.Name, ApexClass.NamespacePrefix ';
apexTestResultQuery += 'FROM ApexTestResult WHERE QueueItemId IN (%s)';
Expand Down Expand Up @@ -372,6 +373,7 @@ export class AsyncTests {
},
runTime: item.RunTime ?? 0,
testTimestamp: item.TestTimestamp, // TODO: convert timestamp
isTestSetup: item.IsTestSetup,
fullName: `${item.ApexClass.FullName}.${item.MethodName}`,
...(diagnostic ? { diagnostic } : {})
});
Expand Down
3 changes: 3 additions & 0 deletions src/tests/syncTests.ts
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,7 @@ export class SyncTests {
testStartTime: formatStartTime(startTime, 'ISO'),
testExecutionTimeInMs: apiTestResult.totalTime ?? 0,
testTotalTimeInMs: apiTestResult.totalTime ?? 0,
testSetupTime: 0,
commandTimeInMs: getCurrentTime() - startTime,
hostname: this.connection.instanceUrl,
orgId: this.connection.getAuthInfoFields().orgId,
Expand Down Expand Up @@ -174,6 +175,7 @@ export class SyncTests {
},
runTime: item.time ?? 0,
testTimestamp: '',
isTestSetup: false,
fullName: `${nms}${item.name}.${item.methodName}`
});
});
Expand Down Expand Up @@ -201,6 +203,7 @@ export class SyncTests {
},
runTime: item.time ?? 0,
testTimestamp: '',
isTestSetup: false,
fullName: `${nms}${item.name}.${item.methodName}`,
...(diagnostic ? { diagnostic } : {})
});
Expand Down
13 changes: 13 additions & 0 deletions src/tests/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -237,6 +237,10 @@ export type ApexTestResultRecord = {
* The start time of the test method.
*/
TestTimestamp: string;
/**
* TODO: Write description
*/
IsTestSetup: boolean;
};

export type ApexTestResult = {
Expand Down Expand Up @@ -272,6 +276,10 @@ export type ApexTestRunResult = {
* The time it took the test to run, in seconds.
*/
TestTime: number | undefined;
/**
* The time it took the test setup to run, in seconds.
*/
TestSetupTime: number;
/**
* The user who ran the test run
*/
Expand Down Expand Up @@ -360,6 +368,10 @@ export type ApexTestResultData = {
* The start time of the test method.
*/
testTimestamp: string;
/**
* TODO: Write description
*/
isTestSetup: boolean;
/**
* The full name of the associated ApexClass method
*/
Expand Down Expand Up @@ -400,6 +412,7 @@ export type TestResult = {
testStartTime: string;
testExecutionTimeInMs: number;
testTotalTimeInMs: number;
testSetupTime: number;
commandTimeInMs: number;
hostname: string;
username: string;
Expand Down
27 changes: 27 additions & 0 deletions test/reporters/testResults.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ export const coverageResult: TestResult = {
testStartTime: isoStartTime,
testExecutionTimeInMs: 5463,
testTotalTimeInMs: 5463,
testSetupTime: 0,
commandTimeInMs: 6000,
testRunId: '7073t000061uwZI',
userId: '0053t000007OxppAAC',
Expand Down Expand Up @@ -51,6 +52,7 @@ export const coverageResult: TestResult = {
fullName: 'AccountServiceTest'
},
runTime: 86,
isTestSetup: false,
testTimestamp: '2020-11-09T18:02:51.000+0000',
fullName: 'AccountServiceTest.should_create_account'
},
Expand All @@ -70,6 +72,7 @@ export const coverageResult: TestResult = {
fullName: 'AwesomeCalculatorTest'
},
runTime: 23,
isTestSetup: false,
testTimestamp: '2020-11-09T18:02:51.000+0000',
fullName: 'AwesomeCalculatorTest.testCallout'
}
Expand Down Expand Up @@ -119,6 +122,7 @@ export const coverageFailResult: TestResult = {
fullName: 'AnimalLocatorTest'
},
runTime: 5,
isTestSetup: false,
testTimestamp: '2020-11-09T18:02:51.000+0000',
fullName: 'AnimalLocatorTest.testMissingAnimal'
}
Expand All @@ -138,6 +142,7 @@ export const successResult: TestResult = {
testStartTime: isoStartTime,
testExecutionTimeInMs: 5463,
testTotalTimeInMs: 5463,
testSetupTime: 0,
commandTimeInMs: 6000,
testRunId: '7073t000061uwZI',
userId: '0053t000007OxppAAC',
Expand All @@ -164,6 +169,7 @@ export const successResult: TestResult = {
fullName: 'AccountServiceTest'
},
runTime: 86,
isTestSetup: false,
testTimestamp: '2020-11-09T18:02:51.000+0000',
fullName: 'AccountServiceTest.should_create_account'
},
Expand All @@ -183,6 +189,7 @@ export const successResult: TestResult = {
fullName: 'AwesomeCalculatorTest'
},
runTime: 23,
isTestSetup: false,
testTimestamp: '2020-11-09T18:02:51.000+0000',
fullName: 'AwesomeCalculatorTest.testCallout'
}
Expand All @@ -200,6 +207,7 @@ export const testResults: TestResult = {
testStartTime: isoStartTime,
testExecutionTimeInMs: 5463,
testTotalTimeInMs: 5463,
testSetupTime: 0,
commandTimeInMs: 6000,
testRunId: '7073t000061uwZI',
userId: '0053t000007OxppAAC',
Expand All @@ -226,6 +234,7 @@ export const testResults: TestResult = {
fullName: 'AccountServiceTest'
},
runTime: 86,
isTestSetup: false,
testTimestamp: '2020-11-09T18:02:51.000+0000',
fullName: 'AccountServiceTest.should_create_account'
},
Expand All @@ -245,6 +254,7 @@ export const testResults: TestResult = {
fullName: 'AwesomeCalculatorTest'
},
runTime: 23,
isTestSetup: false,
testTimestamp: '2020-11-09T18:02:51.000+0000',
fullName: 'AwesomeCalculatorTest.testCallout'
},
Expand All @@ -264,6 +274,7 @@ export const testResults: TestResult = {
fullName: 'trlhdtips.tt_UtilControllerTest'
},
runTime: 13,
isTestSetup: false,
testTimestamp: '2020-11-09T18:02:51.000+0000',
fullName: 'trlhdtips.tt_UtilControllerTest.testGetCurrentUser'
},
Expand All @@ -283,6 +294,7 @@ export const testResults: TestResult = {
fullName: 'trlhdtips.tt_UtilControllerTest'
},
runTime: 179,
isTestSetup: false,
testTimestamp: '2020-11-09T18:02:51.000+0000',
fullName: 'trlhdtips.tt_UtilControllerTest.testResetMyPassword'
},
Expand All @@ -302,6 +314,7 @@ export const testResults: TestResult = {
fullName: 'AnimalLocatorTest'
},
runTime: 16,
isTestSetup: false,
testTimestamp: '2020-11-09T18:02:51.000+0000',
fullName: 'AnimalLocatorTest.testGetCallout'
},
Expand All @@ -323,6 +336,7 @@ export const testResults: TestResult = {
fullName: 'AnimalLocatorTest'
},
runTime: 5,
isTestSetup: false,
testTimestamp: '2020-11-09T18:02:51.000+0000',
fullName: 'AnimalLocatorTest.testMissingAnimal'
},
Expand All @@ -342,6 +356,7 @@ export const testResults: TestResult = {
fullName: 'LeadProcessorTest'
},
runTime: 2256,
isTestSetup: false,
testTimestamp: '2020-11-09T18:02:52.000+0000',
fullName: 'LeadProcessorTest.testProcessing'
},
Expand All @@ -361,6 +376,7 @@ export const testResults: TestResult = {
fullName: 'Dashboard_Pal.DashboardPalTest'
},
runTime: 128,
isTestSetup: false,
testTimestamp: '2020-11-09T18:02:51.000+0000',
fullName: 'Dashboard_Pal.DashboardPalTest.testDashboardPal'
},
Expand All @@ -382,6 +398,7 @@ export const testResults: TestResult = {
fullName: 'AccountProcessorTest'
},
runTime: 241,
isTestSetup: false,
testTimestamp: '2020-11-09T18:02:51.000+0000',
fullName: 'AccountProcessorTest.testCountContacts'
},
Expand All @@ -401,6 +418,7 @@ export const testResults: TestResult = {
fullName: 'AccountProcessorTest'
},
runTime: 10,
isTestSetup: false,
testTimestamp: '2020-11-09T18:02:51.000+0000',
fullName: 'AccountProcessorTest.testCountContactsEmptyList'
},
Expand All @@ -420,6 +438,7 @@ export const testResults: TestResult = {
fullName: 'AccountProcessorTest'
},
runTime: 10,
isTestSetup: false,
testTimestamp: '2020-11-09T18:02:51.000+0000',
fullName: 'AccountProcessorTest.testCountContactsNullList'
},
Expand All @@ -439,6 +458,7 @@ export const testResults: TestResult = {
fullName: 'ParkLocatorTest'
},
runTime: 15,
isTestSetup: false,
testTimestamp: '2020-11-09T18:02:51.000+0000',
fullName: 'ParkLocatorTest.testCallout'
},
Expand All @@ -459,6 +479,7 @@ export const testResults: TestResult = {
fullName: 'AnimalsCalloutsTest'
},
runTime: 28,
isTestSetup: false,
testTimestamp: '2020-11-09T18:02:51.000+0000',
fullName: 'AnimalsCalloutsTest.testGetCallout'
},
Expand All @@ -478,6 +499,7 @@ export const testResults: TestResult = {
fullName: 'AnimalsCalloutsTest'
},
runTime: 7,
isTestSetup: false,
testTimestamp: '2020-11-09T18:02:51.000+0000',
fullName: 'AnimalsCalloutsTest.testPostCallout'
},
Expand All @@ -497,6 +519,7 @@ export const testResults: TestResult = {
fullName: 'AddPrimaryContactTest'
},
runTime: 250,
isTestSetup: false,
testTimestamp: '2020-11-09T18:02:51.000+0000',
fullName: 'AddPrimaryContactTest.testAddContact'
},
Expand All @@ -516,6 +539,7 @@ export const testResults: TestResult = {
fullName: 'DailyLeadProcessorTest'
},
runTime: 2196,
isTestSetup: false,
testTimestamp: '2020-11-09T18:02:51.000+0000',
fullName: 'DailyLeadProcessorTest.testLeadProcessing'
}
Expand All @@ -534,6 +558,7 @@ export const junitResult = `<?xml version="1.0" encoding="UTF-8"?>
<property name="testStartTime" value="${localStartTime}"/>
<property name="testExecutionTime" value="5.46 s"/>
<property name="testTotalTime" value="5.46 s"/>
<property name="testSetupTime" value="0"/>
<property name="commandTime" value="6.00 s"/>
<property name="testRunId" value="7073t000061uwZI"/>
<property name="userId" value="0053t000007OxppAAC"/>
Expand Down Expand Up @@ -590,6 +615,7 @@ const successProperties = ` <property name="failRate" value="0%"/>
<property name="testStartTime" value="${localStartTime}"/>
<property name="testExecutionTime" value="5.46 s"/>
<property name="testTotalTime" value="5.46 s"/>
<property name="testSetupTime" value="0"/>
<property name="commandTime" value="6.00 s"/>
<property name="testRunId" value="7073t000061uwZI"/>
<property name="userId" value="0053t000007OxppAAC"/>
Expand All @@ -606,6 +632,7 @@ const missingValProperties = ` <property name="failRate" value="0%"/>
<property name="testStartTime" value="${localStartTime}"/>
<property name="testExecutionTime" value="5.46 s"/>
<property name="testTotalTime" value="5.46 s"/>
<property name="testSetupTime" value="0"/>
<property name="commandTime" value="6.00 s"/>
<property name="username" value="tpo-3"/>
<property name="failing" value="0"/>
Expand Down
3 changes: 3 additions & 0 deletions test/streaming/testResultStringifyStream.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ const tests = [
asyncApexJobId: 'asyncApexJobId1',
methodName: 'testMethod1',
outcome: ApexTestResultOutcome.Pass,
isTestSetup: false,
apexLogId: null,
apexClass: {
id: 'classId1',
Expand All @@ -38,6 +39,7 @@ const tests = [
asyncApexJobId: 'asyncApexJobId2',
methodName: 'testMethod2',
outcome: ApexTestResultOutcome.Fail,
isTestSetup: false,
apexLogId: 'logId2',
apexClass: {
id: 'classId2',
Expand Down Expand Up @@ -121,6 +123,7 @@ describe('TestResultStringifyStream', () => {
testStartTime: '1641340181000',
testExecutionTimeInMs: 1,
testTotalTimeInMs: 1,
testSetupTime: 0,
commandTimeInMs: 1,
hostname: 'test.salesforce.com',
username: 'test-user@test.com',
Expand Down