Token导航 LogoToken导航TokenDH.com
开发需要联网clawhub未标认证来源可访问clear审计通过

fosmvvm-viewmodel-test-generatorfosmvvm 视图模型测试生成器

Agent Skill

用于辅助测试设计、自动化测试、用例整理和回归验证。它适合让 Agent 编写单元测试、端到端测试、测试计划或根据失败日志定位问题。使用时需要确认项目测试框架、运行命令和夹具数据,避免为了通过测试而改坏真实逻辑;涉及浏览器或外部服务时,应区分本地模拟、测试环境和生产环境。

总安装

15,741

周安装

643

GitHub Stars

公开资料未说明

下载量

5,041
OpenClaw

安装说明

本站只整理中文说明和来源信息,不托管安装包,也不代用户安装。

GitHub

来源数

2

许可证

MIT-0

最后核验

2026-05-01

来源状态

来源可访问

安装方式

通过对话安装

复制提示词发给支持本地命令或 Skills 的 AI 助手,先确认命令和权限,再让它执行。

请帮我安装这个 Agent Skill:fosmvvm-viewmodel-test-generator(fosmvvm 视图模型测试生成器)
来源仓库:https://github.com/foscomputerservices/fosmvvm-viewmodel-test-generator
安装命令:
openclaw skills install fosmvvm-viewmodel-test-generator
安装前请先检查当前环境是否支持对应 CLI,并向我确认将要执行的命令、安装目录、联网范围和文件读写权限;确认后再执行。

命令行安装

复制命令到本机终端执行。该命令会通过 OpenClaw 从第三方来源获取 Skill;本站只展示命令,不托管安装包,也不自动执行。

ClawHubOpenClaw
openclaw skills install fosmvvm-viewmodel-test-generator

简介

fosmvvm-viewmodel-test-generator 可生成具备编码往返和多语言验证的 ViewModel 测试用例。

  • 适用于 .NET MVVM 项目中的单元测试与回归验证。
  • 自动识别模型结构并生成稳定版本兼容的测试代码。
  • 需确保项目使用支持框架且避免在生产环境直接运行测试。
  • 适用宿主包括 OpenClaw,接入前应确认版本、权限和运行环境要求。

SKILL.md

name
fosmvvm-viewmodel-test-generator
description
Generate ViewModel tests with codable round-trip, versioning stability, and multi-locale translation verification.
homepage
https://github.com/foscomputerservices/FOSUtilities
metadata
{"clawdbot": {"emoji": "🔬", "os": ["darwin", "linux"]}}

FOSMVVM ViewModel Test Generator

Generate test files for ViewModels following FOSMVVM testing patterns.

Conceptual Foundation

For full architecture context, see FOSMVVMArchitecture.md | OpenClaw reference

ViewModel testing in FOSMVVM verifies three critical aspects:

  1. Codable round-trip - ViewModel encodes and decodes without data loss
  2. Versioning stability - Structure hasn't changed unexpectedly
  3. Multi-locale translations - All @LocalizedString properties have values in all supported locales

The LocalizableTestCase protocol provides infrastructure that tests all three in a single call.


When to Use This Skill

  • Creating tests for new ViewModels
  • Adding test coverage to existing ViewModels
  • Verifying localization completeness across locales
  • Testing ViewModels with embedded/nested child ViewModels
  • Verifying @LocalizedSubs substitution behavior

What This Skill Generates

FileLocationPurpose
{Name}ViewModelTests.swiftTests/{Target}Tests/Localization/Test suite conforming to LocalizableTestCase
{Name}ViewModel.ymlTests/{Target}Tests/TestYAML/YAML translations for test (if needed)

The Testing Pattern

Standard Pattern (Most Tests)

For most ViewModels, a single line provides complete coverage:

@Test func dashboardViewModel() throws {
    try expectFullViewModelTests(DashboardViewModel.self)
}

This verifies:

  • Codable encoding/decoding
  • Versioned ViewModel stability
  • Translations exist for all locales (en, es by default)

This is sufficient for the vast majority of ViewModel tests.

Extended Pattern (Specific Formatting Verification)

When testing specific formatting behavior (substitutions, compound strings), add locale-specific assertions:

@Test func greetingWithSubstitution() throws {
    try expectFullViewModelTests(GreetingViewModel.self)

    // Verify specific substitution behavior
    let vm: GreetingViewModel = try .stub()
        .toJSON(encoder: encoder(locale: en))
        .fromJSON()

    #expect(try vm.welcomeMessage.localizedString == "Welcome, John!")
}

This is optional - use only when verifying specific formatting techniques.


LocalizableTestCase Protocol

Test suites conform to LocalizableTestCase to access testing infrastructure:

import FOSFoundation
@testable import FOSMVVM
import FOSTesting
import Foundation
import Testing
@testable import {ViewModelsTarget}

@Suite("My ViewModel Tests")
struct MyViewModelTests: LocalizableTestCase {
    let locStore: LocalizationStore

    init() throws {
        self.locStore = try Self.loadLocalizationStore(
            bundle: {ViewModelsTarget}.resourceAccess,
            resourceDirectoryName: ""
        )
    }
}

The {ViewModelsTarget}.resourceAccess is the resource accessor defined when creating the ViewModels SPM target (via FOSResourceAccessor build tool plugin).

What LocalizableTestCase Provides

Property/MethodPurpose
locStoreRequired - the localization store
localesOptional - locales to test (default: en, es)
encoder(locale:)Creates a localizing JSONEncoder
en, es, enGB, enUSLocale constants

Testing Methods

MethodUse When
expectFullViewModelTests(_:)Primary - complete ViewModel testing
expectTranslations(_:)Translation-only verification
expectFullFieldValidationModelTests(_:)Testing FieldValidationModel types
expectFullFormFieldTests(_:)Testing FormField instances
expectCodable(_:encoder:)Codable round-trip only
expectVersionedViewModel(_:encoder:)Versioning stability only

YAML Requirements

ViewModels with @LocalizedString

Every ViewModel with @LocalizedString properties needs YAML entries:

@ViewModel
public struct DashboardViewModel: RequestableViewModel {
    @LocalizedString public var pageTitle      // Needs YAML entry
    @LocalizedString public var emptyMessage   // Needs YAML entry
    public let itemCount: Int                   // No YAML needed
}
# DashboardViewModel.yml
en:
  DashboardViewModel:
    pageTitle: "Dashboard"
    emptyMessage: "No items yet"

es:
  DashboardViewModel:
    pageTitle: "Tablero"
    emptyMessage: "No hay elementos todavía"

Embedded ViewModels

When a ViewModel contains child ViewModels, all types in the hierarchy need YAML entries:

@ViewModel
public struct BoardViewModel: RequestableViewModel {
    @LocalizedString public var title
    public let cards: [CardViewModel]  // Child ViewModel
}

@ViewModel
public struct CardViewModel {
    @LocalizedString public var cardTitle
}

Both BoardViewModel and CardViewModel need YAML entries (can be in same or separate files).

Private Test ViewModels

When tests define private ViewModel structs for testing specific scenarios, those also need YAML:

// In test file
private struct TestParentViewModel: ViewModel {
    @LocalizedString var title
    let children: [TestChildViewModel]
}

private struct TestChildViewModel: ViewModel {
    @LocalizedString var label
}

Add entries to a test YAML file for these private types.


How to Use This Skill

Invocation: /fosmvvm-viewmodel-test-generator

Prerequisites:

  • ViewModel structure understood from conversation context
  • Localization properties identified (@LocalizedString, @LocalizedSubs, etc.)
  • YAML localization files exist or will be created
  • Child ViewModels identified (if any)

Workflow integration: This skill is used when adding test coverage for ViewModels. The skill references conversation context automatically—no file paths or Q&A needed. Typically follows fosmvvm-viewmodel-generator.

Pattern Implementation

This skill references conversation context to determine test structure:

ViewModel Analysis

From conversation context, the skill identifies:

  • ViewModels to test (from prior discussion or codebase)
  • Localization requirements (@LocalizedString properties)
  • Child ViewModels (embedded within parent)
  • Substitution behavior (@LocalizedSubs needing specific verification)

YAML Coverage Check

Verifies completeness:

  • ViewModel YAML entries (all @LocalizedString properties)
  • Child ViewModel entries (nested types)
  • Locale coverage (en, es, or project-specific locales)

Test File Generation

Creates test suite with:

  • LocalizableTestCase conformance
  • Localization store initialization
  • expectFullViewModelTests() calls for each ViewModel
  • Optional specific formatting tests (substitutions, compound strings)

Context Sources

Skill references information from:

  • Prior conversation: ViewModels discussed or recently created
  • ViewModel code: If Claude has read ViewModel files into context
  • YAML files: From codebase analysis of existing localizations
  • Test patterns: From existing test files in project

File Templates

See reference.md for complete file templates.


Common Scenarios

Testing a Single Top-Level ViewModel

@Test func dashboardViewModel() throws {
    try expectFullViewModelTests(DashboardViewModel.self)
}

Testing Multiple Related ViewModels

@Test func boardViewModels() throws {
    try expectFullViewModelTests(BoardViewModel.self)
    try expectFullViewModelTests(ColumnViewModel.self)
    try expectFullViewModelTests(CardViewModel.self)
}

Testing with Custom Locales

var locales: Set<Locale> { [en, es, enGB] }  // Override default

@Test func multiLocaleViewModel() throws {
    try expectFullViewModelTests(MyViewModel.self)
    // Tests en, es, AND en-GB
}

Testing Substitution Behavior

@Test func greetingSubstitutions() throws {
    try expectFullViewModelTests(GreetingViewModel.self)

    let vm: GreetingViewModel = try .stub(userName: "Alice")
        .toJSON(encoder: encoder(locale: en))
        .fromJSON()

    #expect(try vm.welcomeMessage.localizedString == "Welcome, Alice!")
}

Testing Embedded ViewModels

@Test func parentWithChildren() throws {
    // Tests parent AND verifies children can be encoded/decoded
    try expectFullViewModelTests(ParentViewModel.self)

    // Optionally verify specific child values
    let vm: ParentViewModel = try .stub()
        .toJSON(encoder: encoder(locale: en))
        .fromJSON()

    #expect(try vm.children[0].label.localizedString == "Child 1")
}

Troubleshooting

"Missing Translation" Error

FOSLocalizableError: _pageTitle -- Missing Translation -- en

Cause: YAML entry missing for a @LocalizedString property.

Fix: Add the property to the YAML file:

en:
  MyViewModel:
    pageTitle: "Page Title"  # Add this

"Is pending localization" Error

Cause: The ViewModel wasn't encoded with a localizing encoder.

Fix: Ensure using encoder(locale:) or expectFullViewModelTests().

Test Passes But Translations Seem Wrong

Cause: YAML values exist but may have typos or wrong content.

Fix: Add specific assertions to verify exact values:

let vm = try .stub().toJSON(encoder: encoder(locale: en)).fromJSON()
#expect(try vm.title.localizedString == "Expected Value")

Naming Conventions

ConceptConventionExample
Test suite{Feature}ViewModelTestsDashboardViewModelTests
Test file{Feature}ViewModelTests.swiftDashboardViewModelTests.swift
YAML file{ViewModelName}.ymlDashboardViewModel.yml
Test method{viewModelName}() or descriptivedashboardViewModel()

See Also


Version History

VersionDateChanges
1.02025-01-02Initial skill
1.12026-01-19Updated LocalizableTestCase example to use {ViewModelsTarget}.resourceAccess pattern.
1.22026-01-24Update to context-aware approach (remove file-parsing/Q&A). Skill references conversation context instead of asking questions or accepting file paths.

适合场景

01

OpenClaw 用户查找和安装 Skill 时

02

用户想查找某类 Agent Skill 时

03

需要根据任务场景推荐可安装能力包时

04

需要对比不同来源的安装命令和来源信息时

能力概览

能力 1

按任务关键词查找相关 Skills

能力 2

展示可复制的安装命令

能力 3

保留来源站点、仓库和原始说明,方便继续核验

能力 4

补充不同宿主或平台的使用分布数据

能力 5

展示第三方安全扫描或审计结果

安装后应在对应宿主中按原始 README 的触发条件使用;具体调用方式请以来源页面和 README 为准。

平台分布

OpenClaw

88.95%
按下载量换算4,484

安全审计

VirusTotal

通过

ClawScan

通过

Static analysis

未展示

权限和风险

需要联网

该 Skill 可能需要联网访问来源站点、仓库或外部 API;具体网络访问范围需要结合源码和 README 复核。

安装前确认

本站仅展示第三方公开信息,不托管安装包,不提供自动安装或运行环境。安装前应自行审查源码、依赖和命令行为。当前只有一个来源,正式发布前建议补源仓库或其他目录站核验。

来源信息

继续浏览同类 Skills