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

[OpenAPI] Refactoring AdminGetEventDetailsOpenApiTests #322

Merged

Conversation

o-ii
Copy link
Contributor

@o-ii o-ii commented Sep 14, 2024

#207 팔로업 PR

Description

테스트 메서드에서 사용되지 않는 파라미터들이 전달되는 문제 해결

Summary of Changes

  • [MemberData]에서 [InlineData]로 변경: 각 테스트에 필요한 데이터만 직접 제공하도록 [MemberData] 대신 [InlineData]를 사용

  • 불필요한 파라미터 제거: 테스트 메서드에서 사용되지 않는 파라미터를 제거하여 인터페이스를 단순화하고, 필요한 데이터만 처리하도록 개선

Before

public static IEnumerable<object[]> AttributeData =>
    [
        ["eventId", true, "string"],
        ["title", true, "string"],
        // 나머지 데이터 생략
    ];

[Theory]
[MemberData(nameof(AttributeData))]
public async Task Given_Resource_When_Invoked_Endpoint_Then_It_Should_Return_Property(string attribute, bool isRequired, string type)
{
    // Arrange
    using var httpClient = host.App!.CreateHttpClient("apiapp");
    await host.ResourceNotificationService.WaitForResourceAsync("apiapp", KnownResourceStates.Running).WaitAsync(TimeSpan.FromSeconds(30));

    var isReq = isRequired; // 불필요한 변수 할당
    var typeStr = type;     // 불필요한 변수 할당

    // Act & Assert 생략
}

After

[Theory]
[InlineData("eventId")]
[InlineData("title")]
// 나머지 데이터 생략
public async Task Given_Resource_When_Invoked_Endpoint_Then_It_Should_Return_Property(string attribute)
{
    // Arrange
    using var httpClient = host.App!.CreateHttpClient("apiapp");
    await host.ResourceNotificationService.WaitForResourceAsync("apiapp", KnownResourceStates.Running).WaitAsync(TimeSpan.FromSeconds(30));

    // Act & Assert 생략
}

@o-ii o-ii changed the title [OpenAPI] Refactor AdminGetEventDetailsOpenApiTests to use InlineData for test cases [OpenAPI] Refactoring AdminGetEventDetailsOpenApiTests Sep 14, 2024
Copy link
Contributor

@justinyoo justinyoo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

감사합니다!

@justinyoo justinyoo merged commit af47323 into aliencube:main Sep 16, 2024
1 check passed
@o-ii o-ii deleted the refactor/207-endpoint-admin-event-details branch September 21, 2024 05:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants