property-testing

Solid

Property-based testing with fast-check for business logic validation

Testing & QA 183 stars 39 forks Updated 1 months ago MIT

Install

View on GitHub

Quality Score: 88/100

Stars 20%
75
Recency 20%
75
Frontmatter 20%
70
Documentation 15%
100
Issue Health 10%
50
License 10%
100
Description 5%
100

Skill Content

# Property Testing LivestockAI uses property-based testing (PBT) with fast-check to validate business logic invariants. ## What is Property Testing? Instead of testing specific examples, property tests verify that properties hold for ALL possible inputs: ```typescript // Example-based test it('calculates FCR correctly', () => { expect(calculateFCR(150, 100)).toBe(1.5) }) // Property-based test it('FCR is always positive when inputs are positive', () => { fc.assert( fc.property( fc.float({ min: 0.1, max: 10000 }), fc.float({ min: 0.1, max: 10000 }), (feed, weight) => { const fcr = calculateFCR(feed, weight) return fcr === null || fcr > 0 }, ), ) }) ``` ## fast-check Basics ```typescript import { describe, it, expect } from 'vitest' import * as fc from 'fast-check' describe('Property Tests', () => { it('property holds for all inputs', () => { fc.assert( fc.property(fc.integer({ min: 1, max: 100000 }), (quantity) => { // Property must return true or throw return quantity > 0 }), { numRuns: 100 }, ) }) }) ``` ## Common Arbitraries ```typescript // Integers fc.integer({ min: 1, max: 100000 }) fc.nat() // Non-negative integer // Floats fc.float({ min: 0, max: 10000 }) // Strings fc.string() fc.uuid() // Arrays fc.array(fc.integer(), { minLength: 0, maxLength: 20 }) // Objects fc.record({ quantity: fc.integer({ min: 1, max: 1000 }), price: fc.float({ min: 0, max: 100...

Details

Author
majiayu000
Repository
majiayu000/claude-skill-registry
Created
5 months ago
Last Updated
1 months ago
Language
Python
License
MIT

Integrates with

Similar Skills

Semantically similar based on skill content — not just same category