Skip to content

Illustrates a way using Rust lang #rust to randomly generating objects for structs to be able to use them for testing or other reason.

License

Notifications You must be signed in to change notification settings

moaz-mokhtar/mock-generator

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

8 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Mock Generator

Objective

This is to illustrate a functionality which I'm using in my Rust code to generating objects for structs to be able to use them for testing or other reason. This is to minimize developer's efforts to create objects to test.

Plan

  • Develep a basic illustration for the mock generator.
  • Develop test cases which illustrates the benefits of mock_generator.

Design

struct Object {
    pub id: usize,
    pub name: String,
    pub index: i32,
}

impl Object {
    pub fn mock(&self) -> Object {
        // Generate a mock for object which each field will be randomized based on type.
    }

    pub fn mocks(&self, count: i32) -> (Vec<Object>, Duration) {
        // Generate a list of mocks for Object which each field will be randomized based on type.
    }
}

About

Illustrates a way using Rust lang #rust to randomly generating objects for structs to be able to use them for testing or other reason.

Topics

Resources

License

Stars

Watchers

Forks

Languages